Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bat-kryptonyte committed Jul 20, 2023
1 parent cfd6af5 commit 69cb69d
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
uses: wearerequired/lint-action@v2
with:
eslint: true
prettier: true
prettier: true
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@
"prettier --write"
]
}

}
4 changes: 2 additions & 2 deletions src/pages/api/lawProblem.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import type { NextApiRequest, NextApiResponse } from "next";
import { getRandomLawProblem } from "../../server/mongodb/actions/lawProblem";
import requestWrapper from "../../server/utils/middleware";

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const randomProblem = await getRandomLawProblem();
res.status(200).json({ randomProblem });
}
};

export default requestWrapper(handler, "GET");
2 changes: 1 addition & 1 deletion src/pages/api/mathProblem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import type { NextApiRequest, NextApiResponse } from "next";
import { getRandomMathProblem } from "../../server/mongodb/actions/numericalProblem";
import requestWrapper from "../../server/utils/middleware";

Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/mcatReadingProblem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import type { NextApiRequest, NextApiResponse } from "next";
import { getRandomReadingProblem } from "../../server/mongodb/actions/mcatProblem";
import requestWrapper from "../../server/utils/middleware";

Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/mcatScienceImageProblem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import type { NextApiRequest, NextApiResponse } from "next";
import { getRandomScienceImagesProblem } from "../../server/mongodb/actions/mcatProblem";
import requestWrapper from "../../server/utils/middleware";

Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/mcatScienceProblem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import type { NextApiRequest, NextApiResponse } from "next";
import { getRandomScienceProblem } from "../../server/mongodb/actions/mcatProblem";
import requestWrapper from "../../server/utils/middleware";

Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/physicsImgProblem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import type { NextApiRequest, NextApiResponse } from "next";
import { getRandomPhysicsImgProblem } from "../../server/mongodb/actions/numericalProblem";
import requestWrapper from "../../server/utils/middleware";

Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/physicsProblem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import type { NextApiRequest, NextApiResponse } from "next";
import { getRandomPhysicsProblem } from "../../server/mongodb/actions/numericalProblem";
import requestWrapper from "../../server/utils/middleware";

Expand Down
4 changes: 1 addition & 3 deletions src/screens/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export default function Home() {
.then((data) => {
console.log(data);
setProblem(data["randomProblem"]);

});
};

Expand All @@ -75,7 +74,6 @@ export default function Home() {
setAnswerCandidates(problem["Answer Candidates"]);
}
setFinalAnswer(problem["Final Answer"]);

}
}, [problem]);

Expand Down Expand Up @@ -126,7 +124,7 @@ export default function Home() {
<br />
<br />
<div>
{!isNumericalProblem(problem) && <strong>Answer Candidates:</strong>}
{!isNumericalProblem(problem) && <strong>Answer Candidates:</strong>}
{!isNumericalProblem(problem) &&
answerCandidates &&
answerCandidates.map((answer, index) => {
Expand Down
14 changes: 7 additions & 7 deletions src/server/utils/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import connectDb from '../mongodb/connectDb';
import type { NextApiRequest, NextApiResponse } from "next";

Check failure on line 1 in src/server/utils/middleware.ts

View workflow job for this annotation

GitHub Actions / Prettier

src/server/utils/middleware.ts#L1

There are issues with this file's formatting, please run Prettier to fix the errors
import connectDb from "../mongodb/connectDb";

type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
type RequestMethod = "GET" | "POST" | "PUT" | "DELETE";

export default function requestWrapper(
handler: (req: NextApiRequest, res: NextApiResponse) => void | Promise<void>,
Expand All @@ -11,18 +11,18 @@ export default function requestWrapper(
if (req.method !== method) {
return res.status(400).json({
success: false,
message: 'Request Failure: Invalid method for request',
message: "Request Failure: Invalid method for request",
});
}

if (method !== 'GET') {
if (method !== "GET") {
try {
req.body = JSON.parse(req.body);
} catch (error) {
console.log(error);
return res.status(400).json({
success: false,
message: 'Invalid request body',
message: "Invalid request body",
});
}
}
Expand All @@ -36,7 +36,7 @@ export default function requestWrapper(
console.error(error);
return res.status(500).json({
success: false,
message: 'Server Error',
message: "Server Error",
});
}

Expand Down
5 changes: 4 additions & 1 deletion src/server/utils/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const sendRequest = async (route: string, method: "GET" | "POST" | "PUT" | "DELETE"): Promise<any> => {
const sendRequest = async (

Check failure on line 1 in src/server/utils/request.ts

View workflow job for this annotation

GitHub Actions / Prettier

src/server/utils/request.ts#L1

There are issues with this file's formatting, please run Prettier to fix the errors
route: string,
method: "GET" | "POST" | "PUT" | "DELETE"
): Promise<any> => {
let result: Response;
if (method === "GET") {
result = await fetch(route);
Expand Down

0 comments on commit 69cb69d

Please sign in to comment.