Skip to content

Commit

Permalink
[#140] refactor(@aops/transactionHandler): 파리미터 명 변경(service -> contr…
Browse files Browse the repository at this point in the history
…ollerFunc)
  • Loading branch information
skid901 committed Dec 19, 2020
1 parent 4bcf780 commit 5e13658
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/src/aops/transactionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import mongoose from 'mongoose';
import { NextFunction, Request, Response } from 'express';

export const transactionHandler = (
service: (req: Request, res: Response, next?: NextFunction) => Promise<any>,
controllerFunc: (
req: Request,
res: Response,
next?: NextFunction,
) => Promise<any>,
) => async (
req: Request,
res: Response,
Expand All @@ -11,7 +15,7 @@ export const transactionHandler = (
const session = await mongoose.startSession();
session.startTransaction();
try {
const rtn = await service(req, res, next);
await controllerFunc(req, res, next);
await session.commitTransaction();
session.endSession();
} catch (err) {
Expand Down

0 comments on commit 5e13658

Please sign in to comment.