Skip to content

Commit

Permalink
Add support for RAR (#211)
Browse files Browse the repository at this point in the history
* Added runes and riddles changes

* Fixed build

* Added the code
  • Loading branch information
AydanPirani authored Feb 24, 2024
1 parent 9e14bbf commit d48e9ca
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .test.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ SPARKPOST_KEY = "123456789"

FCM_SERVICE_ACCOUNT = "abcd"

QID0 = "qid"
QID1 = "qid"
QID2 = "qid"
QID3 = "qid"
QID4 = "qid"
QID5 = "qid"
QID6 = "qid"
QID7 = "qid"
QID8 = "qid"
QID9 = "qid"
QID8 = "qid"
4 changes: 2 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import morgan from "morgan";
import morgan from "morgan";
import express, { Application, Request, Response } from "express";

import admissionRouter from "./services/admission/admission-router.js";
Expand Down Expand Up @@ -31,7 +31,7 @@ app.use(corsSelector);

// Enable request output when not a test
if (!Config.TEST) {
// app.use(morgan("dev"));
app.use(morgan("dev"));
}

// Automatically convert requests from json
Expand Down
12 changes: 7 additions & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export enum Device {
IOS = "ios",
ANDROID = "android",
CHALLENGE = "challenge",
PUZZLE = "puzzle",
}

export enum RegistrationTemplates {
Expand Down Expand Up @@ -63,13 +64,14 @@ const Config = {
[Device.CHALLENGE, "https://adonix.hackillinois.org/auth/dev/"],
[Device.IOS, "hackillinois://login/"],
[Device.ANDROID, "hackillinois://login/"],
[Device.PUZZLE, "http://localhost:5173/auth/"],
]) as Map<string, string>,

CALLBACK_URLS: {
GITHUB: "https://adonix.hackillinois.org/auth/github/callback/",
// GITHUB: "http://localhost:3000/auth/github/callback/",
GOOGLE: "https://adonix.hackillinois.org/auth/google/callback/",
// GOOGLE: "http://127.0.0.1:3000/auth/google/callback/",
// GITHUB: "https://adonix.hackillinois.org/auth/github/callback/",
// GOOGLE: "https://adonix.hackillinois.org/auth/google/callback/",
GITHUB: "http://localhost:3000/auth/github/callback/",
GOOGLE: "http://127.0.0.1:3000/auth/google/callback/",
},

METADATA_URL: "https://hackillinois.github.io/adonix-metadata/config.json",
Expand Down Expand Up @@ -105,6 +107,7 @@ const Config = {

// Runes and Riddles
PUZZLE: [
requireEnv("QID0"),
requireEnv("QID1"),
requireEnv("QID2"),
requireEnv("QID3"),
Expand All @@ -113,7 +116,6 @@ const Config = {
requireEnv("QID6"),
requireEnv("QID7"),
requireEnv("QID8"),
requireEnv("QID9"),
],
PUZZLE_EVENT_END_TIME: 1708812000,
TRUE_VALUE: 1,
Expand Down
3 changes: 3 additions & 0 deletions src/services/auth/auth-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ authRouter.get(
case Device.IOS:
token = generateJwtToken(payload, true);
break;
case Device.PUZZLE:
token = generateJwtToken(payload, true);
break;
default:
token = generateJwtToken(payload, false);
}
Expand Down
20 changes: 13 additions & 7 deletions src/services/puzzle/puzzle-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,24 @@ puzzleRouter.post("/create", strongJwtVerification, async (req: Request, res: Re

try {
// Create a new PuzzleItem model
const newPuzzleItem = new Models.PuzzleItem({
userId: targetUser,
teamName: teamName,
lastCorrect: Config.PUZZLE_EVENT_END_TIME,
problemComplete: [false, false, false, false, false, false, false, false, false, false],
score: 0,
});
const newPuzzleItem = new PuzzleItem(targetUser, teamName, Config.PUZZLE_EVENT_END_TIME, 0, [
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
]);

await Models.PuzzleItem.findOneAndUpdate({ userId: targetUser }, newPuzzleItem, { upsert: true, new: true });

return res.status(StatusCode.SuccessOK).send({ newPuzzleItem });
} catch (error) {
console.log(error);
return res.status(StatusCode.ServerErrorInternal).send({ status: false, error: "Internal Server Error" });
}
});
Expand Down

0 comments on commit d48e9ca

Please sign in to comment.