Skip to content

Commit

Permalink
lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa-lopes-pt committed Jun 23, 2024
1 parent 7ece332 commit 9119554
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 100 deletions.
3 changes: 1 addition & 2 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import dotenv from "dotenv";
import MongoClientWrapper from "./database/MongoClientWrapper";
import server from "./server";
import dbClient from "./database/DatabaseClient";
import server from "./server";

dotenv.config();

Expand Down
10 changes: 10 additions & 0 deletions backend/src/routes/controllers/account/account.router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import express from "express";
import authMiddleware from "../../middleware/auth.middleware";

const router = express.Router();

router.get("/test", authMiddleware, (_, res) => {
res.status(200).json();
});

export default router;
3 changes: 1 addition & 2 deletions backend/src/routes/controllers/auth/signup.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { NextFunction, Request, Response } from "express";
import HTTPCodes from "simple-http-codes";
import { SignupSchemaType } from "../../../../../shared/schemas/signup.schema";

import { UserSchemaType } from "../../../../../shared/schemas/user.schema";
import { DbUserSchemaType } from "../../../repositories/DbUser.type";
import HttpError from "../../../utils/HttpError";
import { hashData } from "../../../utils/crypto";
import { authRepo } from "./auth.router";
import { DbUserSchemaType } from "../../../repositories/DbUser.type";

export default async function signupController(
req: Request,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextFunction, Request, Response } from "express";
import { AnyZodObject, ZodError, z } from "zod";
import { ZodError, z } from "zod";
import HttpError from "../../utils/HttpError";

export default function createBodyValidatorMiddleware(schema: z.ZodSchema) {
Expand Down
9 changes: 6 additions & 3 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import cookieParser from "cookie-parser";
import cors from "cors";
import express, { NextFunction, Request, Response } from "express";
import morgan from "morgan";
import HTTPCodes from "simple-http-codes";
import timeoutMiddleware from "./routes/middleware/timeout.middleware";
import router from "./routes/router";
import HttpError from "./utils/HttpError";
import timeoutMiddleware from "./routes/middleware/timeout.middleware";
import cookieParser from "cookie-parser";
const server = express();
server.use(morgan("dev"));
server.use(cors());
Expand All @@ -25,7 +25,7 @@ server.use(router);

//====== ERROR HANDLING

server.use((error: Error, _req: Request, res: Response, next: NextFunction) => {
server.use((error: Error, _req: Request, res: Response, _next: NextFunction) => {
if (error instanceof HttpError) {
error.log();
return res
Expand All @@ -35,10 +35,13 @@ server.use((error: Error, _req: Request, res: Response, next: NextFunction) => {

console.error(error);


return res.status(500).json({
message: "Unexpected Server Error, please contact development team",
error,
});

_next()//just so that eslint doesn't complain...its a very specific scenario, don't blame me
});

server.use("*", (_, res) => {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/utils/HttpError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const ErrorCodes = {
type HttpErrorContext = {
error?: unknown;
cause?: string;
context?: any;
context?: unknown;
};

export default class HttpError extends Error {
Expand Down
182 changes: 91 additions & 91 deletions backend/tsconfig.json

Large diffs are not rendered by default.

0 comments on commit 9119554

Please sign in to comment.