-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed05be1
commit 75e0d63
Showing
30 changed files
with
2,237 additions
and
1,335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mongodb_uri=mongodb+srv://hackatank:[email protected] | ||
mongodb_collection="hackatank" | ||
sheetsId="112d2-Xz4IFCGa6z03NaYRgO9crvLWeMnbuzKrzL0mxU" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { config } from "dotenv"; | ||
config(); | ||
import { MongoClient } from "mongodb"; | ||
import express from "express"; | ||
import cors from "cors"; | ||
import sheet from "./sheetsService.mjs"; | ||
import path from "path"; | ||
import bodyParser from "body-parser"; | ||
const __dirname = path.resolve(); | ||
const app = express(); | ||
const port = 4444; | ||
const mongo_uri = process.env.mongodb_uri; | ||
const client = new MongoClient(mongo_uri); | ||
client.connect(); | ||
|
||
client.on("open", () => console.log("Connected To Database")); | ||
client.on("error", (err) => console.log("Error Occurred - MongoDB", err)); | ||
client.on("close", () => console.log("Disconnected from mongodb")); | ||
|
||
const corsOptions = { | ||
origin: ["https://hackatank.tech"], | ||
}; | ||
app.use(express.json()); | ||
app.post("/api/verify", cors(corsOptions), async (req, res) => { | ||
const requestData = req.body; | ||
|
||
const id = parseInt(requestData.id); | ||
const code = requestData.code; | ||
const authBy = requestData.authemail; | ||
|
||
const db = client.db(process.env.mongodb_collection); | ||
const response = await db.collection("qr-details").findOne({ | ||
id, | ||
}); | ||
if (response) { | ||
const timestamp = new Date().toString(); | ||
const name = response.name; | ||
const Sheetres = await sheet([[id, timestamp, name, code, authBy]]); | ||
|
||
return res.status(200).json({ name, id, code }); | ||
} else { | ||
return res.status(404).json({ error: "Not found", id }); | ||
} | ||
}); | ||
|
||
app.use(express.static(path.join(__dirname, "dist"))); | ||
app.get( | ||
["/", "/about", "/set1", "/set2", "/events", "/guidelines", "/judges"], | ||
(req, res) => { | ||
res.status(200).sendFile(path.join(__dirname, "dist", "index.html")); | ||
} | ||
); | ||
|
||
app.use((req, res) => { | ||
res.status(404).sendFile(path.join(__dirname, "dist", "index.html")); | ||
}); | ||
app.listen(port, () => console.log("Server Started on port: ", port)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { google } from "googleapis"; | ||
import { config } from "dotenv"; | ||
config(); | ||
const scope = ["https://www.googleapis.com/auth/spreadsheets"]; | ||
const sheetId = process.env.sheetsId; | ||
|
||
export default async function sheet(values) { | ||
const auth = new google.auth.GoogleAuth({ | ||
keyFile: "./sheets_creds.json", | ||
scopes: scope[0], | ||
}); | ||
|
||
const sheets = google.sheets({ | ||
version: "v4", | ||
auth, | ||
}); | ||
|
||
const data = await sheets.spreadsheets.values.append({ | ||
auth, | ||
spreadsheetId: sheetId, | ||
valueInputOption: "USER_ENTERED", | ||
insertDataOption: "INSERT_ROWS", | ||
range: "Sheet1", | ||
resource: { | ||
values: values, | ||
}, | ||
}); | ||
|
||
return data.status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"type": "service_account", | ||
"project_id": "hackatank-1834c", | ||
"private_key_id": "c09c7c021ec68939f0904056a432c06058470d06", | ||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCqGlhKL24Y/hT6\nbXckMyasyFtHrrl2tLShmeNR/hg7yPCj4t4qB+jOM4/O1YQLz94H60aUQVXxrjkJ\nvs7qtHwfIHzyYTlQ5GVSkYvfIE2VSJaOqUZrqqb5yqTu/r1tKdyrQY80nwPMVx9n\n35PVqz5Iufra2i0imRgHWx1aEJH2QG16WXwb1W0teTgMIUuebJ7xHGWd0OhhJdZx\nku7Ov6+iHZex8XaVMvOC5a85YkVWMHG4QV87CupkMwtYH81vHFfW1ujiQhsmB06p\nNb3KdO8S6uS7bY18YRQlD/BNMeKhqk5YoDkWLTdSmuQ8XQfhtSZEQtiCi05yVnc5\nT4pvLGPXAgMBAAECggEAJ4JS+3gkxF1PlhMS1y+iTgODYBTvMukqA1bw+7xe+JPl\ngMtS+sQ3iJ1lS49ASlYPphs5m3nJcoca7G6LNOyS38/19X4rh+RkvFbd/AdOvdvM\nTHp4xs0uV1qAEJrOeKp+fLCPiJNemHmr6758YeaSYuX/pBGE5kJU2HCLUr4CiQVw\n3ngR1XrFTSIbR7a3Z6g5e8WkDUEYv4qlIOvJQsoFhYfQlf0z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id": "108756465124561266376", | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://oauth2.googleapis.com/token", | ||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", | ||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/hackathon-qr%40hackatank-1834c.iam.gserviceaccount.com", | ||
"universe_domain": "googleapis.com" | ||
} |
Oops, something went wrong.