Skip to content

Commit

Permalink
fix: request in register alarm #89
Browse files Browse the repository at this point in the history
  • Loading branch information
dragontaek-lee committed Jun 18, 2023
1 parent 5e36ba1 commit bff6880
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/constants/responseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ export default {
//alarm
PUSH_NOTIFICATION_SUCCESS: "알람 전송 성공",
PUSH_NOTIFICATION_FALED: "알람 전송 실패",
PUSH_NOTIFICATION_REGISTER_SUCCESS: "유저 구독 성공",
PUSH_NOTIFICATION_REGISTER_FALED: "유저 구독 실패",
};
6 changes: 5 additions & 1 deletion src/controller/alarmController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ const register = async (req: Request, res: Response, next: NextFunction) => {
return next(new PicmeException(sc.BAD_REQUEST, false, rm.BAD_REQUEST));
}

const userId = req.body.userId;

if (!userId) return next(new PicmeException(sc.UNAUTHORIZED, false, rm.INVALID_TOKEN));

const alarmRegisterDTO: AlarmRegisterDTO = req.body;

try {
await alarmService.register(alarmRegisterDTO);

return res.status(sc.OK).send(success(sc.OK, rm.PUSH_NOTIFICATION_SUCCESS));
return res.status(sc.OK).send(success(sc.OK, rm.PUSH_NOTIFICATION_REGISTER_SUCCESS));
} catch (e) {
return next(e);
}
Expand Down
9 changes: 8 additions & 1 deletion src/middlewares/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { fail } from "../constants/response";
import tokenType from "../constants/tokenType";
import jwtHandler from "../modules/jwtHandler";

const skipAuthPath = ["/sticker", "/auth", "/user/name", "/user/email", "/vote/common", "/alarm"];
const skipAuthPath = [
"/sticker",
"/auth",
"/user/name",
"/user/email",
"/vote/common",
"/alarm/push",
];
const uploadPath = "/vote";

export default async (req: Request, res: Response, next: NextFunction) => {
Expand Down
2 changes: 1 addition & 1 deletion src/router/alarmRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ router.post(
//register notification
router.post(
"/register",
[body("userId").notEmpty(), body("endpoint").notEmpty(), body("keys").notEmpty()],
[body("endpoint").notEmpty(), body("expirationTime"), body("keys").notEmpty()],
alarmController.register
);

Expand Down

0 comments on commit bff6880

Please sign in to comment.