Skip to content

Commit

Permalink
[#152] feat: 페이지 리스트 변경사항 publish 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
domino8788 committed Dec 20, 2020
1 parent bd9eb00 commit 430a6da
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/src/controllers/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const create = transactionHandler(
async (req: Request, res: Response): Promise<void> => {
const page = await pageService.create(req.body.page);
const pages = await pageService.readAll();
req.app.get('io').of('/pageList').emit('PageListUpdate', pages);
res.status(StatusCode.CREATED).json({ page, pages });
},
);
Expand All @@ -23,13 +24,16 @@ export const readAll = async (req: Request, res: Response): Promise<void> => {

export const update = async (req: Request, res: Response): Promise<void> => {
const page = await pageService.update(req.params.pageId, req.body.page);
const pages = await pageService.readAll();
req.app.get('io').of('/pageList').emit('PageListUpdate', pages);
res.status(StatusCode.OK).json({ page });
};

export const deleteOne = transactionHandler(
async (req: Request, res: Response): Promise<void> => {
await pageService.deleteOne(req.params.pageId);
const pages = await pageService.readAll();
req.app.get('io').of('/pageList').emit('PageListUpdate', pages);
res.status(StatusCode.OK).json({ pages });
},
);

0 comments on commit 430a6da

Please sign in to comment.