@taladel/common 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.
package/dist/index.d.ts CHANGED
@@ -6,10 +6,11 @@ export { correlationIdMiddleware, getCorrelationId, } from './correlation/middle
6
6
  * Export the types
7
7
  */
8
8
  export type { CorrelationIdOptions, RequestWithCorrelation, } from './correlation/types';
9
- export type { jwtPayload as JwtPayload, } from './services/jwt.service';
10
- export type { CustomError, } from './errors/custom-error';
11
- export type { default as Authenticate, } from './middlewares/auth-req';
12
- export type { default as ErrorHandler, } from './middlewares/error-handler';
13
- export type { correlationIdMiddleware as CorrelationIdMiddleware, } from './correlation/middleware';
14
- export type { getCorrelationId as GetCorrelationId, } from './correlation/middleware';
9
+ export * from './services/jwt.service';
10
+ export * from './services/password.service';
11
+ export * from './errors/custom-error';
12
+ export * from './middlewares/auth-req';
13
+ export * from './middlewares/error-handler';
14
+ export * from './correlation/middleware';
15
+ export * from './correlation/types';
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACH,uBAAuB,EACvB,gBAAgB,GACnB,MAAM,0BAA0B,CAAC;AAGlC;;GAEG;AACH,YAAY,EACR,oBAAoB,EACpB,sBAAsB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,YAAW,EACP,UAAU,IAAI,UAAU,GAC3B,MAAM,wBAAwB,CAAC;AAEhC,YAAW,EACP,WAAW,GACd,MAAM,uBAAuB,CAAC;AAE/B,YAAW,EACP,OAAO,IAAI,YAAY,GAC1B,MAAM,wBAAwB,CAAC;AAEhC,YAAW,EACP,OAAO,IAAI,YAAY,GAC1B,MAAM,6BAA6B,CAAC;AAErC,YAAW,EACP,uBAAuB,IAAI,uBAAuB,GACrD,MAAM,0BAA0B,CAAC;AAElC,YAAW,EACP,gBAAgB,IAAI,gBAAgB,GACvC,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACH,uBAAuB,EACvB,gBAAgB,GACnB,MAAM,0BAA0B,CAAC;AAElC;;GAEG;AACH,YAAY,EACR,oBAAoB,EACpB,sBAAsB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,uBAAuB,CAAC;AAEtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAG5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.getCorrelationId = exports.correlationIdMiddleware = void 0;
4
18
  /**
@@ -7,4 +21,11 @@ exports.getCorrelationId = exports.correlationIdMiddleware = void 0;
7
21
  var middleware_1 = require("./correlation/middleware");
8
22
  Object.defineProperty(exports, "correlationIdMiddleware", { enumerable: true, get: function () { return middleware_1.correlationIdMiddleware; } });
9
23
  Object.defineProperty(exports, "getCorrelationId", { enumerable: true, get: function () { return middleware_1.getCorrelationId; } });
24
+ __exportStar(require("./services/jwt.service"), exports);
25
+ __exportStar(require("./services/password.service"), exports);
26
+ __exportStar(require("./errors/custom-error"), exports);
27
+ __exportStar(require("./middlewares/auth-req"), exports);
28
+ __exportStar(require("./middlewares/error-handler"), exports);
29
+ __exportStar(require("./correlation/middleware"), exports);
30
+ __exportStar(require("./correlation/types"), exports);
10
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,uDAGkC;AAF9B,qHAAA,uBAAuB,OAAA;AACvB,8GAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,uDAGkC;AAF9B,qHAAA,uBAAuB,OAAA;AACvB,8GAAA,gBAAgB,OAAA;AAWpB,yDAAuC;AACvC,8DAA4C;AAE5C,wDAAsC;AAEtC,yDAAuC;AACvC,8DAA4C;AAG5C,2DAAyC;AACzC,sDAAoC"}
@@ -0,0 +1,4 @@
1
+ import { Request, Response, NextFunction } from "express";
2
+ export declare const validateRequest: (req: Request, res: Response, next: NextFunction) => void;
3
+ export default validateRequest;
4
+ //# sourceMappingURL=validate-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-request.d.ts","sourceRoot":"","sources":["../../src/middlewares/validate-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI1D,eAAO,MAAM,eAAe,GAAI,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,KAAG,IASjF,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateRequest = void 0;
4
+ const express_validator_1 = require("express-validator");
5
+ const custom_error_1 = require("../errors/custom-error");
6
+ const validateRequest = (req, res, next) => {
7
+ const errors = (0, express_validator_1.validationResult)(req);
8
+ if (!errors.isEmpty()) {
9
+ throw new custom_error_1.CustomError(400, errors.array()[0].msg);
10
+ return;
11
+ }
12
+ next();
13
+ };
14
+ exports.validateRequest = validateRequest;
15
+ exports.default = exports.validateRequest;
16
+ //# sourceMappingURL=validate-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-request.js","sourceRoot":"","sources":["../../src/middlewares/validate-request.ts"],"names":[],"mappings":";;;AACA,yDAAqD;AACrD,yDAAqD;AAE9C,MAAM,eAAe,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;IACrF,MAAM,MAAM,GAAG,IAAA,oCAAgB,EAAC,GAAG,CAAC,CAAC;IAErC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,0BAAW,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAClD,OAAO;IACX,CAAC;IAED,IAAI,EAAE,CAAC;AACX,CAAC,CAAC;AATW,QAAA,eAAe,mBAS1B;AAEF,kBAAe,uBAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taladel/common",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "common utilities for microservices",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,15 +20,16 @@
20
20
  "express": "^5.2.1"
21
21
  },
22
22
  "dependencies": {
23
+ "bcryptjs": "^3.0.3",
23
24
  "cls-rtracer": "^2.6.3",
24
- "jsonwebtoken": "^9.0.3",
25
- "bcryptjs": "^3.0.3"
25
+ "express-validator": "^7.3.1",
26
+ "jsonwebtoken": "^9.0.3"
26
27
  },
27
28
  "devDependencies": {
29
+ "@types/bcryptjs": "^2.4.6",
28
30
  "@types/express": "^5.0.6",
29
31
  "@types/jsonwebtoken": "^9.0.10",
30
32
  "@types/node": "^25.0.6",
31
- "@types/bcryptjs": "^2.4.6",
32
33
  "typescript": "^5.9.3"
33
34
  }
34
35
  }
package/src/index.ts CHANGED
@@ -6,7 +6,6 @@ export {
6
6
  getCorrelationId,
7
7
  } from './correlation/middleware';
8
8
 
9
-
10
9
  /**
11
10
  * Export the types
12
11
  */
@@ -15,26 +14,14 @@ export type {
15
14
  RequestWithCorrelation,
16
15
  } from './correlation/types';
17
16
 
18
- export type{
19
- jwtPayload as JwtPayload,
20
- } from './services/jwt.service';
21
-
22
- export type{
23
- CustomError,
24
- } from './errors/custom-error';
17
+ export * from './services/jwt.service';
18
+ export * from './services/password.service';
25
19
 
26
- export type{
27
- default as Authenticate,
28
- } from './middlewares/auth-req';
20
+ export * from './errors/custom-error';
29
21
 
30
- export type{
31
- default as ErrorHandler,
32
- } from './middlewares/error-handler';
22
+ export * from './middlewares/auth-req';
23
+ export * from './middlewares/error-handler';
33
24
 
34
- export type{
35
- correlationIdMiddleware as CorrelationIdMiddleware,
36
- } from './correlation/middleware';
37
25
 
38
- export type{
39
- getCorrelationId as GetCorrelationId,
40
- } from './correlation/middleware';
26
+ export * from './correlation/middleware';
27
+ export * from './correlation/types';
@@ -0,0 +1,16 @@
1
+ import { Request, Response, NextFunction } from "express";
2
+ import { validationResult } from "express-validator";
3
+ import { CustomError } from "../errors/custom-error";
4
+
5
+ export const validateRequest = (req: Request, res: Response, next: NextFunction): void => {
6
+ const errors = validationResult(req);
7
+
8
+ if (!errors.isEmpty()) {
9
+ throw new CustomError(400, errors.array()[0].msg);
10
+ return;
11
+ }
12
+
13
+ next();
14
+ };
15
+
16
+ export default validateRequest;