Skip to content

Commit

Permalink
Fixed naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
AydanPirani committed Apr 11, 2024
1 parent dc4b9c8 commit 7aab40d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ app.use("/event", eventRouter);
app.use("/subscription", subscriptionRouter);

app.get("/status", (_, res) => {
console.log(StatusCodes.OK);
return res.status(StatusCodes.OK).send("API is alive!");
});

Expand Down
6 changes: 3 additions & 3 deletions src/middleware/role-checker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextFunction, Request, Response } from "express";
import { JwtPayload, Role } from "../services/auth/auth-models";
import { JwtPayloadValidator, Role } from "../services/auth/auth-models";
import { z } from "zod";
import jsonwebtoken from "jsonwebtoken";
import { Config } from "../config";
Expand All @@ -21,12 +21,12 @@ export default function RoleChecker(
}

try {
console.log("in");
const payloadData = jsonwebtoken.verify(
jwt,
Config.JWT_SIGNING_SECRET
);
const payload = JwtPayload.parse(payloadData);

const payload = JwtPayloadValidator.parse(payloadData);
res.locals.payload = payload;

const error = new Error("InvalidRoles");
Expand Down
2 changes: 1 addition & 1 deletion src/services/auth/auth-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from "zod";

export const Role = z.enum(["USER", "ADMIN", "CORPORATE"]);

export const JwtPayload = z.object({
export const JwtPayloadValidator = z.object({
userId: z.string(),
roles: Role.array(),
});

0 comments on commit 7aab40d

Please sign in to comment.