Skip to content

Commit

Permalink
refactor: change middleware name
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhiz committed May 2, 2023
1 parent 1158c89 commit da9b559
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/middlewares/schema.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const schemaMiddleware = (schema: Schema) => {
...req.body,
...req.query
});
const result = schema.safeParse(res.locals.sanitizedRequestData);
const result = schema.safeParse(res.locals.sanitizedRequest);

if (!result.success && 'error' in result) {
const errorMessages = result.error.issues.map((issue: ZodIssue) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type JWTPayload = {
userId: number;
};

const authMiddleware = async (req: Request, res: Response, next: NextFunction) => {
const tokenMiddleware = async (req: Request, res: Response, next: NextFunction) => {
const { authorization } = req.headers;
const token = authorization?.split(' ')[1]?.trim();

Expand All @@ -25,4 +25,4 @@ const authMiddleware = async (req: Request, res: Response, next: NextFunction) =
next();
};

export default authMiddleware;
export default tokenMiddleware;
2 changes: 1 addition & 1 deletion src/routes/exemple.route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// import { Router } from 'express';
// import authMiddleware from '../middlewares/auth.middleware';
// import tokenMiddleware from "../middlewares/token.middleware";
// import schemaMiddleware from "../middlewares/schema.middleware";

// const exampleRouter = Router();
Expand Down

0 comments on commit da9b559

Please sign in to comment.