@beautinique/be-middlewares 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from 'express';
|
|
2
2
|
import { ClientSession } from 'mongoose';
|
|
3
|
-
export declare const tryCatch: (fn: (req:
|
|
4
|
-
export declare const tryCatchWithSession: (fn: (req:
|
|
3
|
+
export declare const tryCatch: <T extends Request>(fn: (req: T, res: Response, next: NextFunction) => Promise<any>) => (req: T, res: Response, next: NextFunction) => void;
|
|
4
|
+
export declare const tryCatchWithSession: <T extends Request>(fn: (req: T, res: Response, session: ClientSession) => Promise<any>) => (req: T, res: Response, next: NextFunction) => Promise<void>;
|
|
@@ -4,16 +4,16 @@ exports.tryCatchWithSession = exports.tryCatch = void 0;
|
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
5
|
const tryCatch = (fn) => {
|
|
6
6
|
return (req, res, next) => {
|
|
7
|
-
fn(req, res, next).catch(next);
|
|
7
|
+
Promise.resolve(fn(req, res, next)).catch(next);
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
exports.tryCatch = tryCatch;
|
|
11
11
|
const tryCatchWithSession = (fn) => {
|
|
12
12
|
return async (req, res, next) => {
|
|
13
13
|
const session = await (0, mongoose_1.startSession)();
|
|
14
|
-
session.startTransaction();
|
|
15
14
|
try {
|
|
16
|
-
|
|
15
|
+
session.startTransaction();
|
|
16
|
+
await Promise.resolve(fn(req, res, session));
|
|
17
17
|
await session.commitTransaction();
|
|
18
18
|
}
|
|
19
19
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tryCatch.response.middleware.js","sourceRoot":"","sources":["../../../src/middlewares/response-middlewares/tryCatch.response.middleware.ts"],"names":[],"mappings":";;;AACA,uCAAuD;AAEhD,MAAM,QAAQ,GAAG,CACtB,
|
|
1
|
+
{"version":3,"file":"tryCatch.response.middleware.js","sourceRoot":"","sources":["../../../src/middlewares/response-middlewares/tryCatch.response.middleware.ts"],"names":[],"mappings":";;;AACA,uCAAuD;AAEhD,MAAM,QAAQ,GAAG,CACtB,EAA+D,EAC/D,EAAE;IACF,OAAO,CAAC,GAAM,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;QACnD,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,QAAQ,YAMnB;AAEK,MAAM,mBAAmB,GAAG,CACjC,EAAmE,EACnE,EAAE;IACF,OAAO,KAAK,EAAE,GAAM,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;QACzD,MAAM,OAAO,GAAG,MAAM,IAAA,uBAAY,GAAE,CAAC;QAErC,IAAI,CAAC;YACH,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAE3B,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;YAE7C,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;QACpC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,CAAC,gBAAgB,EAAE,CAAC;YACjC,IAAI,CAAC,GAAG,CAAC,CAAC;QACZ,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,mBAAmB,uBAmB9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beautinique/be-middlewares",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Middlewares for the Beautinique backend project.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@beautinique/be-classes": "^1.0.1",
|
|
43
43
|
"@beautinique/be-constants": "^1.0.6",
|
|
44
44
|
"@beautinique/be-utils": "^1.0.3",
|
|
45
|
-
"@beautinique/be-zod": "^1.0.
|
|
45
|
+
"@beautinique/be-zod": "^1.0.16",
|
|
46
46
|
"multer": "^2.1.1",
|
|
47
47
|
"winston": "^3.19.0"
|
|
48
48
|
}
|