Skip to content

Commit

Permalink
Prettify the code
Browse files Browse the repository at this point in the history
  • Loading branch information
yitong241 committed Oct 3, 2024
1 parent 7862aaf commit 8dd36fc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
11 changes: 7 additions & 4 deletions backend/question-service/src/routes/questionRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const router: Router = Router();

// Create a new question (POST)
router.post("/", async (req: Request, res: Response) => {
const { questionId, title, description, categories, complexity, link } = req.body;
const { questionId, title, description, categories, complexity, link } =
req.body;

try {
const newQuestion = new Question({
Expand Down Expand Up @@ -52,9 +53,10 @@ router.put("/:id", async (req: Request, res: Response) => {
const updatedQuestion = await Question.findOneAndUpdate(
{ questionId: req.params.id },
{ title, description, categories, complexity },
{ new: true }
{ new: true },
);
if (!updatedQuestion) return res.status(404).json({ error: "Question not found" });
if (!updatedQuestion)
return res.status(404).json({ error: "Question not found" });
res.json(updatedQuestion);
} catch (err) {
res.status(500).json({ error: (err as Error).message });
Expand All @@ -67,7 +69,8 @@ router.delete("/:id", async (req: Request, res: Response) => {
const deletedQuestion = await Question.findOneAndDelete({
questionId: req.params.id,
});
if (!deletedQuestion) return res.status(404).json({ error: "Question not found" });
if (!deletedQuestion)
return res.status(404).json({ error: "Question not found" });
res.json({ message: "Question deleted successfully" });
} catch (err) {
res.status(500).json({ error: (err as Error).message });
Expand Down
14 changes: 7 additions & 7 deletions backend/question-service/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "ES6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ES6" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
Expand All @@ -25,7 +25,7 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"module": "commonjs" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down Expand Up @@ -57,7 +57,7 @@
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
// "removeComments": true, /* Disable emitting comments. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
Expand All @@ -77,12 +77,12 @@
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -105,7 +105,7 @@

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion frontend/src/pages/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Login = (): ReactElement => {
if (email === "[email protected]" && password === "password") {
setLoading(true);
setTimeout(() => {
navigate("/");
navigate("/");
}, 3000);
} else {
setLoginError("Invalid email or password.");
Expand Down

0 comments on commit 8dd36fc

Please sign in to comment.