@impactor/nest 3.0.2 → 5.0.0
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/index.d.ts +41 -41
- package/package.json +29 -33
- package/src/configs/app.d.ts +5 -4
- package/src/configs/app.js +10 -18
- package/src/configs/app.js.map +1 -1
- package/src/configs/database.js +1 -11
- package/src/configs/database.js.map +1 -1
- package/src/configs/microservice.js +6 -16
- package/src/configs/microservice.js.map +1 -1
- package/src/configs/multi-queue-rabbitmq-server.js +28 -34
- package/src/configs/multi-queue-rabbitmq-server.js.map +1 -1
- package/src/configs/redis-config.js +1 -11
- package/src/configs/redis-config.js.map +1 -1
- package/src/create-app.d.ts +1 -1
- package/src/create-app.js +44 -61
- package/src/create-app.js.map +1 -1
- package/src/create-microservice.d.ts +1 -1
- package/src/create-microservice.js +18 -22
- package/src/create-microservice.js.map +1 -1
- package/src/create-testing-microservice.d.ts +1 -1
- package/src/create-testing-microservice.js +16 -20
- package/src/create-testing-microservice.js.map +1 -1
- package/src/decorators/controller/add-decorators/add-controller-path.d.ts +1 -1
- package/src/decorators/controller/add-decorators/add-controller-path.js +7 -15
- package/src/decorators/controller/add-decorators/add-controller-path.js.map +1 -1
- package/src/decorators/controller/add-decorators/add-controller-tags.d.ts +1 -1
- package/src/decorators/controller/add-decorators/add-controller-tags.js +9 -17
- package/src/decorators/controller/add-decorators/add-controller-tags.js.map +1 -1
- package/src/decorators/controller/add-decorators/add-http-method.d.ts +2 -2
- package/src/decorators/controller/add-decorators/add-http-method.js +13 -20
- package/src/decorators/controller/add-decorators/add-http-method.js.map +1 -1
- package/src/decorators/controller/add-decorators/add-swagger-body.d.ts +2 -2
- package/src/decorators/controller/add-decorators/add-swagger-body.js +7 -17
- package/src/decorators/controller/add-decorators/add-swagger-body.js.map +1 -1
- package/src/decorators/controller/add-decorators/add-swagger-operation.d.ts +2 -2
- package/src/decorators/controller/add-decorators/add-swagger-operation.js +8 -15
- package/src/decorators/controller/add-decorators/add-swagger-operation.js.map +1 -1
- package/src/decorators/controller/add-decorators/add-swagger-params.d.ts +2 -2
- package/src/decorators/controller/add-decorators/add-swagger-params.js +9 -16
- package/src/decorators/controller/add-decorators/add-swagger-params.js.map +1 -1
- package/src/decorators/controller/add-decorators/add-swagger-response.d.ts +2 -2
- package/src/decorators/controller/add-decorators/add-swagger-response.js +10 -20
- package/src/decorators/controller/add-decorators/add-swagger-response.js.map +1 -1
- package/src/decorators/controller/controller.decorator.d.ts +1 -1
- package/src/decorators/controller/controller.decorator.js +12 -13
- package/src/decorators/controller/controller.decorator.js.map +1 -1
- package/src/decorators/controller/controller.factory.d.ts +1 -1
- package/src/decorators/controller/controller.factory.js +59 -67
- package/src/decorators/controller/controller.factory.js.map +1 -1
- package/src/decorators/controller/default-options.d.ts +1 -1
- package/src/decorators/controller/default-options.js +11 -26
- package/src/decorators/controller/default-options.js.map +1 -1
- package/src/decorators/controller/dto/empty.dto.js +2 -12
- package/src/decorators/controller/dto/empty.dto.js.map +1 -1
- package/src/decorators/controller/dto/update-response.dto.js +2 -12
- package/src/decorators/controller/dto/update-response.dto.js.map +1 -1
- package/src/decorators/controller/interceptors/query.interceptor.d.ts +1 -1
- package/src/decorators/controller/interceptors/query.interceptor.js +10 -19
- package/src/decorators/controller/interceptors/query.interceptor.js.map +1 -1
- package/src/decorators/controller/route-handler.d.ts +2 -2
- package/src/decorators/controller/route-handler.js +8 -16
- package/src/decorators/controller/route-handler.js.map +1 -1
- package/src/decorators/controller/route.decorator.d.ts +1 -1
- package/src/decorators/controller/route.decorator.js +11 -11
- package/src/decorators/controller/route.decorator.js.map +1 -1
- package/src/decorators/controller/services/crud-typeorm.service.d.ts +1 -2
- package/src/decorators/controller/services/crud-typeorm.service.js +19 -24
- package/src/decorators/controller/services/crud-typeorm.service.js.map +1 -1
- package/src/decorators/controller/types/index.d.ts +2 -2
- package/src/decorators/controller/types/index.js +1 -4
- package/src/decorators/controller/types/index.js.map +1 -1
- package/src/decorators/controller/utils/merge-options.d.ts +1 -1
- package/src/decorators/controller/utils/merge-options.js +3 -13
- package/src/decorators/controller/utils/merge-options.js.map +1 -1
- package/src/decorators/controller/utils/reflect.d.ts +2 -2
- package/src/decorators/controller/utils/reflect.js +24 -38
- package/src/decorators/controller/utils/reflect.js.map +1 -1
- package/src/decorators/entity.decorator.js +42 -35
- package/src/decorators/entity.decorator.js.map +1 -1
- package/src/decorators/prop.decorator.js +79 -38
- package/src/decorators/prop.decorator.js.map +1 -1
- package/src/exceptions/rpc-bad-request.exception.d.ts +1 -1
- package/src/exceptions/rpc-bad-request.exception.js +5 -15
- package/src/exceptions/rpc-bad-request.exception.js.map +1 -1
- package/src/exceptions/rpc-base.exception.js +10 -15
- package/src/exceptions/rpc-base.exception.js.map +1 -1
- package/src/exceptions/rpc-conflict.exception.d.ts +1 -1
- package/src/exceptions/rpc-conflict.exception.js +5 -15
- package/src/exceptions/rpc-conflict.exception.js.map +1 -1
- package/src/exceptions/rpc-internal-server-error.exception.d.ts +1 -1
- package/src/exceptions/rpc-internal-server-error.exception.js +5 -15
- package/src/exceptions/rpc-internal-server-error.exception.js.map +1 -1
- package/src/exceptions/rpc-method-not-allowed.exception.d.ts +1 -1
- package/src/exceptions/rpc-method-not-allowed.exception.js +5 -15
- package/src/exceptions/rpc-method-not-allowed.exception.js.map +1 -1
- package/src/exceptions/rpc-not-found.exception.d.ts +1 -1
- package/src/exceptions/rpc-not-found.exception.js +5 -15
- package/src/exceptions/rpc-not-found.exception.js.map +1 -1
- package/src/exceptions/rpc-not-implemented.exception.d.ts +1 -1
- package/src/exceptions/rpc-not-implemented.exception.js +5 -15
- package/src/exceptions/rpc-not-implemented.exception.js.map +1 -1
- package/src/exceptions/rpc-unauthorized.exception.d.ts +1 -1
- package/src/exceptions/rpc-unauthorized.exception.js +5 -15
- package/src/exceptions/rpc-unauthorized.exception.js.map +1 -1
- package/src/filters/error-to-rpc-exception.filter.js +12 -22
- package/src/filters/error-to-rpc-exception.filter.js.map +1 -1
- package/src/filters/error-to-ws-exception.filter.js +10 -20
- package/src/filters/error-to-ws-exception.filter.js.map +1 -1
- package/src/filters/typeorm-exception.filter.js +9 -19
- package/src/filters/typeorm-exception.filter.js.map +1 -1
- package/src/filters/ws-exception.filter.js +6 -16
- package/src/filters/ws-exception.filter.js.map +1 -1
- package/src/generate-metadata.d.ts +3 -3
- package/src/generate-metadata.js +18 -74
- package/src/generate-metadata.js.map +1 -1
- package/src/guards/auth.guard.js +43 -44
- package/src/guards/auth.guard.js.map +1 -1
- package/src/modules/basic/basic.controller.js +6 -16
- package/src/modules/basic/basic.controller.js.map +1 -1
- package/src/modules/basic/basic.module.js +15 -23
- package/src/modules/basic/basic.module.js.map +1 -1
- package/src/modules/basic/basic.service.js +4 -14
- package/src/modules/basic/basic.service.js.map +1 -1
- package/src/register-entities.js +37 -20
- package/src/register-entities.js.map +1 -1
- package/src/utils/logger.js +2 -12
- package/src/utils/logger.js.map +1 -1
- package/src/utils/typeorm-to-swagger.d.ts +1 -1
- package/src/utils/typeorm-to-swagger.js +4 -11
- package/src/utils/typeorm-to-swagger.js.map +1 -1
- package/nx.json +0 -190
- package/src/nest-swagger-metadata.js +0 -593
- package/src/nest-swagger-metadata.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/decorators/controller/utils/reflect.ts"],"sourcesContent":["import { UseInterceptors } from '@nestjs/common';\nimport { ControllerFactory } from '../controller.factory';\nimport { IRoute } from '../types';\n\n/**\n * Check if the class or a method has a metadata property\n * @param property the metadata property to be checked\n * @param factory the class\n * @param route if provided, the method's metadata is checked, otherwise the class's metadata is checked\n * @returns\n */\nexport function has(\n property: string,\n factory: ControllerFactory,\n route?: IRoute,\n) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.hasMetadata(\n property,\n factory.controller.prototype[route.methodName],\n )\n : Reflect.hasMetadata(property, factory.controller.prototype) ||\n Reflect.hasMetadata(property, factory.controller);\n}\n\nexport function get(\n property: string,\n factory: ControllerFactory,\n route?: IRoute,\n) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.getMetadata(\n property,\n factory.controller.prototype[route.methodName],\n )\n : Reflect.getMetadata(property, factory.controller.prototype) ||\n Reflect.getMetadata(property, factory.controller);\n}\n\nexport function set<T extends Object>(\n property: string,\n value: T,\n factory: ControllerFactory,\n route?: IRoute,\n) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.defineMetadata(\n property,\n value,\n factory.controller.prototype[route.methodName],\n )\n : Reflect.defineMetadata(property, value, factory.controller.prototype);\n}\n\n/**\n * get all metadata keys\n * @param factory\n * @param route\n */\nexport function getKeys(factory: ControllerFactory, route?: IRoute) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.getMetadataKeys(factory.controller.prototype[route.methodName])\n : [\n ...new Set([\n ...Reflect.getMetadataKeys(factory.controller.prototype),\n ...Reflect.getMetadataKeys(factory.controller),\n ]),\n ];\n}\n\n/**\n * get all metadata key-value pairs\n * @param factory\n * @param route\n */\nexport function getAll(factory: ControllerFactory, route?: IRoute) {\n let keys = getKeys(factory, route);\n let map: { [key: string]: unknown } = {};\n\n for (let key of keys) {\n map[key] = get(key, factory, route);\n }\n\n return map;\n}\n\n/**\n * apply the provided decorators to the method\n */\nexport function applyDecorators(factory: ControllerFactory) {\n if (factory.decorators?.length) {\n Reflect.decorate(factory.decorators, factory.controller);\n }\n\n for (let route of factory.options.routes) {\n // without reflect-metadata use: `decorator(target, method, descriptor)`\n if (route.decorators?.length) {\n Reflect.decorate(\n route.decorators,\n factory.controller.prototype,\n route.methodName,\n Reflect.getOwnPropertyDescriptor(\n factory.controller.prototype,\n route.methodName,\n ),\n );\n\n if (route.interceptors?.length) {\n Reflect.decorate(\n [UseInterceptors(...route.interceptors)],\n factory.controller.prototype,\n route.methodName,\n Reflect.getOwnPropertyDescriptor(\n factory.controller.prototype,\n route.methodName,\n ),\n );\n }\n }\n }\n}\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../../../src/decorators/controller/utils/reflect.ts"],"sourcesContent":["import { UseInterceptors } from '@nestjs/common';\nimport { ControllerFactory } from '../controller.factory.js';\nimport { IRoute } from '../types/index.js';\n\n/**\n * Check if the class or a method has a metadata property\n * @param property the metadata property to be checked\n * @param factory the class\n * @param route if provided, the method's metadata is checked, otherwise the class's metadata is checked\n * @returns\n */\nexport function has(\n property: string,\n factory: ControllerFactory,\n route?: IRoute,\n) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.hasMetadata(\n property,\n factory.controller.prototype[route.methodName],\n )\n : Reflect.hasMetadata(property, factory.controller.prototype) ||\n Reflect.hasMetadata(property, factory.controller);\n}\n\nexport function get(\n property: string,\n factory: ControllerFactory,\n route?: IRoute,\n) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.getMetadata(\n property,\n factory.controller.prototype[route.methodName],\n )\n : Reflect.getMetadata(property, factory.controller.prototype) ||\n Reflect.getMetadata(property, factory.controller);\n}\n\nexport function set<T extends Object>(\n property: string,\n value: T,\n factory: ControllerFactory,\n route?: IRoute,\n) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.defineMetadata(\n property,\n value,\n factory.controller.prototype[route.methodName],\n )\n : Reflect.defineMetadata(property, value, factory.controller.prototype);\n}\n\n/**\n * get all metadata keys\n * @param factory\n * @param route\n */\nexport function getKeys(factory: ControllerFactory, route?: IRoute) {\n if (route && !route.methodName) {\n throw new Error(\n `route's methodName is not provided (${route.httpMethod?.toUpperCase()} ${route.path})`,\n );\n }\n\n return route\n ? Reflect.getMetadataKeys(factory.controller.prototype[route.methodName])\n : [\n ...new Set([\n ...Reflect.getMetadataKeys(factory.controller.prototype),\n ...Reflect.getMetadataKeys(factory.controller),\n ]),\n ];\n}\n\n/**\n * get all metadata key-value pairs\n * @param factory\n * @param route\n */\nexport function getAll(factory: ControllerFactory, route?: IRoute) {\n let keys = getKeys(factory, route);\n let map: { [key: string]: unknown } = {};\n\n for (let key of keys) {\n map[key] = get(key, factory, route);\n }\n\n return map;\n}\n\n/**\n * apply the provided decorators to the method\n */\nexport function applyDecorators(factory: ControllerFactory) {\n if (factory.decorators?.length) {\n Reflect.decorate(factory.decorators, factory.controller);\n }\n\n for (let route of factory.options.routes) {\n // without reflect-metadata use: `decorator(target, method, descriptor)`\n if (route.decorators?.length) {\n Reflect.decorate(\n route.decorators,\n factory.controller.prototype,\n route.methodName,\n Reflect.getOwnPropertyDescriptor(\n factory.controller.prototype,\n route.methodName,\n ),\n );\n\n if (route.interceptors?.length) {\n Reflect.decorate(\n [UseInterceptors(...route.interceptors)],\n factory.controller.prototype,\n route.methodName,\n Reflect.getOwnPropertyDescriptor(\n factory.controller.prototype,\n route.methodName,\n ),\n );\n }\n }\n }\n}\n"],"names":["UseInterceptors","has","property","factory","route","methodName","Error","httpMethod","toUpperCase","path","Reflect","hasMetadata","controller","prototype","get","getMetadata","set","value","defineMetadata","getKeys","getMetadataKeys","Set","getAll","keys","map","key","applyDecorators","decorators","length","decorate","options","routes","getOwnPropertyDescriptor","interceptors"],"mappings":"AAAA,SAASA,eAAe,QAAQ,iBAAiB;AAIjD;;;;;;CAMC,GACD,OAAO,SAASC,IACdC,QAAgB,EAChBC,OAA0B,EAC1BC,KAAc;IAEd,IAAIA,SAAS,CAACA,MAAMC,UAAU,EAAE;QAC9B,MAAM,IAAIC,MACR,CAAC,oCAAoC,EAAEF,MAAMG,UAAU,EAAEC,cAAc,CAAC,EAAEJ,MAAMK,IAAI,CAAC,CAAC,CAAC;IAE3F;IAEA,OAAOL,QACHM,QAAQC,WAAW,CACjBT,UACAC,QAAQS,UAAU,CAACC,SAAS,CAACT,MAAMC,UAAU,CAAC,IAEhDK,QAAQC,WAAW,CAACT,UAAUC,QAAQS,UAAU,CAACC,SAAS,KACxDH,QAAQC,WAAW,CAACT,UAAUC,QAAQS,UAAU;AACxD;AAEA,OAAO,SAASE,IACdZ,QAAgB,EAChBC,OAA0B,EAC1BC,KAAc;IAEd,IAAIA,SAAS,CAACA,MAAMC,UAAU,EAAE;QAC9B,MAAM,IAAIC,MACR,CAAC,oCAAoC,EAAEF,MAAMG,UAAU,EAAEC,cAAc,CAAC,EAAEJ,MAAMK,IAAI,CAAC,CAAC,CAAC;IAE3F;IAEA,OAAOL,QACHM,QAAQK,WAAW,CACjBb,UACAC,QAAQS,UAAU,CAACC,SAAS,CAACT,MAAMC,UAAU,CAAC,IAEhDK,QAAQK,WAAW,CAACb,UAAUC,QAAQS,UAAU,CAACC,SAAS,KACxDH,QAAQK,WAAW,CAACb,UAAUC,QAAQS,UAAU;AACxD;AAEA,OAAO,SAASI,IACdd,QAAgB,EAChBe,KAAQ,EACRd,OAA0B,EAC1BC,KAAc;IAEd,IAAIA,SAAS,CAACA,MAAMC,UAAU,EAAE;QAC9B,MAAM,IAAIC,MACR,CAAC,oCAAoC,EAAEF,MAAMG,UAAU,EAAEC,cAAc,CAAC,EAAEJ,MAAMK,IAAI,CAAC,CAAC,CAAC;IAE3F;IAEA,OAAOL,QACHM,QAAQQ,cAAc,CACpBhB,UACAe,OACAd,QAAQS,UAAU,CAACC,SAAS,CAACT,MAAMC,UAAU,CAAC,IAEhDK,QAAQQ,cAAc,CAAChB,UAAUe,OAAOd,QAAQS,UAAU,CAACC,SAAS;AAC1E;AAEA;;;;CAIC,GACD,OAAO,SAASM,QAAQhB,OAA0B,EAAEC,KAAc;IAChE,IAAIA,SAAS,CAACA,MAAMC,UAAU,EAAE;QAC9B,MAAM,IAAIC,MACR,CAAC,oCAAoC,EAAEF,MAAMG,UAAU,EAAEC,cAAc,CAAC,EAAEJ,MAAMK,IAAI,CAAC,CAAC,CAAC;IAE3F;IAEA,OAAOL,QACHM,QAAQU,eAAe,CAACjB,QAAQS,UAAU,CAACC,SAAS,CAACT,MAAMC,UAAU,CAAC,IACtE;WACK,IAAIgB,IAAI;eACNX,QAAQU,eAAe,CAACjB,QAAQS,UAAU,CAACC,SAAS;eACpDH,QAAQU,eAAe,CAACjB,QAAQS,UAAU;SAC9C;KACF;AACP;AAEA;;;;CAIC,GACD,OAAO,SAASU,OAAOnB,OAA0B,EAAEC,KAAc;IAC/D,IAAImB,OAAOJ,QAAQhB,SAASC;IAC5B,IAAIoB,MAAkC,CAAC;IAEvC,KAAK,IAAIC,OAAOF,KAAM;QACpBC,GAAG,CAACC,IAAI,GAAGX,IAAIW,KAAKtB,SAASC;IAC/B;IAEA,OAAOoB;AACT;AAEA;;CAEC,GACD,OAAO,SAASE,gBAAgBvB,OAA0B;IACxD,IAAIA,QAAQwB,UAAU,EAAEC,QAAQ;QAC9BlB,QAAQmB,QAAQ,CAAC1B,QAAQwB,UAAU,EAAExB,QAAQS,UAAU;IACzD;IAEA,KAAK,IAAIR,SAASD,QAAQ2B,OAAO,CAACC,MAAM,CAAE;QACxC,wEAAwE;QACxE,IAAI3B,MAAMuB,UAAU,EAAEC,QAAQ;YAC5BlB,QAAQmB,QAAQ,CACdzB,MAAMuB,UAAU,EAChBxB,QAAQS,UAAU,CAACC,SAAS,EAC5BT,MAAMC,UAAU,EAChBK,QAAQsB,wBAAwB,CAC9B7B,QAAQS,UAAU,CAACC,SAAS,EAC5BT,MAAMC,UAAU;YAIpB,IAAID,MAAM6B,YAAY,EAAEL,QAAQ;gBAC9BlB,QAAQmB,QAAQ,CACd;oBAAC7B,mBAAmBI,MAAM6B,YAAY;iBAAE,EACxC9B,QAAQS,UAAU,CAACC,SAAS,EAC5BT,MAAMC,UAAU,EAChBK,QAAQsB,wBAAwB,CAC9B7B,QAAQS,UAAU,CAACC,SAAS,EAC5BT,MAAMC,UAAU;YAGtB;QACF;IACF;AACF"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { registerEntities } from "../register-entities.js";
|
|
2
|
+
import { Entity as TypeORMEntity, getMetadataArgsStorage } from "typeorm";
|
|
3
|
+
import { snakeCase } from "typeorm/util/StringUtils.js";
|
|
4
|
+
/**
|
|
5
|
+
* Define a class as a TypeORM entity
|
|
6
|
+
* - add Swagger decorators to all columns
|
|
7
|
+
*
|
|
8
|
+
* note: currently, this decorator ignores `@ApiHideProperty()`
|
|
9
|
+
* use `@Hide()` instead
|
|
10
|
+
* https://github.com/nestjs/swagger/issues/3711
|
|
11
|
+
*/ // todo: add basic columns such as id, created_at, updated_at
|
|
12
|
+
// this has a downside, that TS cannot detect props that are defined dynamically
|
|
13
|
+
// i.e. `Model.id` will cause a TS error
|
|
14
|
+
// todo: add class validator decorators from column definition
|
|
15
|
+
// for instance `@Column(type: 'varchar', length: 200)` -> `@IsString() @MaxLength(200)`
|
|
16
|
+
// note that we cannot access uninitialized classes properties,
|
|
17
|
+
// so `this.model[col.propertyName]` is always undefined,
|
|
18
|
+
// also Reflect methods cannot be used to decorate those properties as they are not existing
|
|
19
|
+
// otherwise use a property decorator to work with each property separately
|
|
20
|
+
// todo: create `@Column()` decorator to apply these steps on property-level
|
|
21
|
+
// this has a downside: it'll use the property name rather than the final column name,
|
|
22
|
+
// because TypeORM may rename the column using a naming strategy
|
|
23
|
+
// so, we need to access the naming strategy to apply it on each prop
|
|
24
|
+
export function Entity(name, options) {
|
|
23
25
|
return (target)=>{
|
|
24
26
|
new EntityFactory(target, {
|
|
25
27
|
name,
|
|
@@ -28,14 +30,23 @@ function Entity(name, options) {
|
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
32
|
let EntityFactory = class EntityFactory {
|
|
33
|
+
constructor(model, options){
|
|
34
|
+
this.model = model;
|
|
35
|
+
this.options = options;
|
|
36
|
+
/**
|
|
37
|
+
* contains all TypeORM metadata for all entities
|
|
38
|
+
*/ this.storage = getMetadataArgsStorage();
|
|
39
|
+
this.addEntity();
|
|
40
|
+
this.addSwaggerDecorators();
|
|
41
|
+
}
|
|
31
42
|
/**
|
|
32
43
|
* decorate the class with TypeORM `@Entity()`
|
|
33
44
|
*/ addEntity() {
|
|
34
45
|
// TypeORM's `@Entity()` adds the class to storage.tables
|
|
35
46
|
if (!this.storage.tables.some((el)=>el.target === this.model)) {
|
|
36
47
|
Reflect.decorate([
|
|
37
|
-
(
|
|
38
|
-
|
|
48
|
+
TypeORMEntity(this.options?.name || // todo: generate plural names
|
|
49
|
+
snakeCase(this.model.name.replace(/(Entity|DTO|Model)$/i, '') + 's'), this.options)
|
|
39
50
|
], this.model);
|
|
40
51
|
}
|
|
41
52
|
}
|
|
@@ -43,21 +54,17 @@ let EntityFactory = class EntityFactory {
|
|
|
43
54
|
* add Swagger decorators to all the model fields
|
|
44
55
|
*/ addSwaggerDecorators() {
|
|
45
56
|
// todo: also get the class that this.model extends, if any.
|
|
46
|
-
|
|
57
|
+
registerEntities([
|
|
47
58
|
this.model
|
|
48
59
|
]);
|
|
49
60
|
}
|
|
50
|
-
constructor(model, options){
|
|
51
|
-
this.model = model;
|
|
52
|
-
this.options = options;
|
|
53
|
-
/**
|
|
54
|
-
* contains all TypeORM metadata for all entities
|
|
55
|
-
*/ this.storage = (0, _typeorm.getMetadataArgsStorage)();
|
|
56
|
-
this.addEntity();
|
|
57
|
-
this.addSwaggerDecorators();
|
|
58
|
-
}
|
|
59
61
|
};
|
|
60
|
-
|
|
62
|
+
/**
|
|
63
|
+
* add `@Hide()` to properties that you don't want to hide in Swagger
|
|
64
|
+
* Using `@ApiHideProperty()` from `@nestjs/swagger` is not supported
|
|
65
|
+
* `@ApiHideProperty()` doesn't add a metadata -> use `@Hide()`
|
|
66
|
+
* https://github.com/nestjs/swagger/blob/master/lib/decorators/api-hide-property.decorator.ts
|
|
67
|
+
*/ export function Hide() {
|
|
61
68
|
return (target, key)=>{
|
|
62
69
|
Reflect.defineMetadata('swagger/apiModelProperties', false, target, key);
|
|
63
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/decorators/entity.decorator.ts"],"sourcesContent":["import { registerEntities } from '../register-entities';\nimport {\n Entity as TypeORMEntity,\n EntityOptions,\n getMetadataArgsStorage,\n} from 'typeorm';\nimport { MetadataArgsStorage } from 'typeorm/metadata-args/MetadataArgsStorage';\nimport { snakeCase } from 'typeorm/util/StringUtils';\n\nexport interface IEntityOptions extends EntityOptions {\n name?: string;\n}\n\n/**\n * Define a class as a TypeORM entity\n * - add Swagger decorators to all columns\n *\n * note: currently, this decorator ignores `@ApiHideProperty()`\n * use `@Hide()` instead\n * https://github.com/nestjs/swagger/issues/3711\n */\n// todo: add basic columns such as id, created_at, updated_at\n// this has a downside, that TS cannot detect props that are defined dynamically\n// i.e. `Model.id` will cause a TS error\n// todo: add class validator decorators from column definition\n// for instance `@Column(type: 'varchar', length: 200)` -> `@IsString() @MaxLength(200)`\n// note that we cannot access uninitialized classes properties,\n// so `this.model[col.propertyName]` is always undefined,\n// also Reflect methods cannot be used to decorate those properties as they are not existing\n// otherwise use a property decorator to work with each property separately\n// todo: create `@Column()` decorator to apply these steps on property-level\n// this has a downside: it'll use the property name rather than the final column name,\n// because TypeORM may rename the column using a naming strategy\n// so, we need to access the naming strategy to apply it on each prop\nexport function Entity(name?: string, options?: EntityOptions): ClassDecorator {\n return (target: Function) => {\n new EntityFactory(target, { name, ...options });\n };\n}\n\nclass EntityFactory {\n /**\n * contains all TypeORM metadata for all entities\n */\n private storage: MetadataArgsStorage = getMetadataArgsStorage();\n\n constructor(\n private model: Function,\n private options?: IEntityOptions,\n ) {\n this.addEntity();\n this.addSwaggerDecorators();\n }\n\n /**\n * decorate the class with TypeORM `@Entity()`\n */\n addEntity() {\n // TypeORM's `@Entity()` adds the class to storage.tables\n if (!this.storage.tables.some((el) => el.target === this.model)) {\n Reflect.decorate(\n [\n TypeORMEntity(\n this.options?.name ||\n // todo: generate plural names\n snakeCase(\n this.model.name.replace(/(Entity|DTO|Model)$/i, '') + 's',\n ),\n this.options,\n ),\n ],\n this.model,\n );\n }\n }\n\n /**\n * add Swagger decorators to all the model fields\n */\n addSwaggerDecorators() {\n // todo: also get the class that this.model extends, if any.\n registerEntities([this.model]);\n }\n}\n\n/**\n * add `@Hide()` to properties that you don't want to hide in Swagger\n * Using `@ApiHideProperty()` from `@nestjs/swagger` is not supported\n * `@ApiHideProperty()` doesn't add a metadata -> use `@Hide()`\n * https://github.com/nestjs/swagger/blob/master/lib/decorators/api-hide-property.decorator.ts\n */\nexport function Hide(): PropertyDecorator {\n return (target: Object, key: string | symbol) => {\n Reflect.defineMetadata('swagger/apiModelProperties', false, target, key);\n };\n}\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../src/decorators/entity.decorator.ts"],"sourcesContent":["import { registerEntities } from '../register-entities.js';\nimport {\n Entity as TypeORMEntity,\n EntityOptions,\n getMetadataArgsStorage,\n} from 'typeorm';\nimport { MetadataArgsStorage } from 'typeorm/metadata-args/MetadataArgsStorage.js';\nimport { snakeCase } from 'typeorm/util/StringUtils.js';\n\nexport interface IEntityOptions extends EntityOptions {\n name?: string;\n}\n\n/**\n * Define a class as a TypeORM entity\n * - add Swagger decorators to all columns\n *\n * note: currently, this decorator ignores `@ApiHideProperty()`\n * use `@Hide()` instead\n * https://github.com/nestjs/swagger/issues/3711\n */\n// todo: add basic columns such as id, created_at, updated_at\n// this has a downside, that TS cannot detect props that are defined dynamically\n// i.e. `Model.id` will cause a TS error\n// todo: add class validator decorators from column definition\n// for instance `@Column(type: 'varchar', length: 200)` -> `@IsString() @MaxLength(200)`\n// note that we cannot access uninitialized classes properties,\n// so `this.model[col.propertyName]` is always undefined,\n// also Reflect methods cannot be used to decorate those properties as they are not existing\n// otherwise use a property decorator to work with each property separately\n// todo: create `@Column()` decorator to apply these steps on property-level\n// this has a downside: it'll use the property name rather than the final column name,\n// because TypeORM may rename the column using a naming strategy\n// so, we need to access the naming strategy to apply it on each prop\nexport function Entity(name?: string, options?: EntityOptions): ClassDecorator {\n return (target: Function) => {\n new EntityFactory(target, { name, ...options });\n };\n}\n\nclass EntityFactory {\n /**\n * contains all TypeORM metadata for all entities\n */\n private storage: MetadataArgsStorage = getMetadataArgsStorage();\n\n constructor(\n private model: Function,\n private options?: IEntityOptions,\n ) {\n this.addEntity();\n this.addSwaggerDecorators();\n }\n\n /**\n * decorate the class with TypeORM `@Entity()`\n */\n addEntity() {\n // TypeORM's `@Entity()` adds the class to storage.tables\n if (!this.storage.tables.some((el) => el.target === this.model)) {\n Reflect.decorate(\n [\n TypeORMEntity(\n this.options?.name ||\n // todo: generate plural names\n snakeCase(\n this.model.name.replace(/(Entity|DTO|Model)$/i, '') + 's',\n ),\n this.options,\n ),\n ],\n this.model,\n );\n }\n }\n\n /**\n * add Swagger decorators to all the model fields\n */\n addSwaggerDecorators() {\n // todo: also get the class that this.model extends, if any.\n registerEntities([this.model]);\n }\n}\n\n/**\n * add `@Hide()` to properties that you don't want to hide in Swagger\n * Using `@ApiHideProperty()` from `@nestjs/swagger` is not supported\n * `@ApiHideProperty()` doesn't add a metadata -> use `@Hide()`\n * https://github.com/nestjs/swagger/blob/master/lib/decorators/api-hide-property.decorator.ts\n */\nexport function Hide(): PropertyDecorator {\n return (target: Object, key: string | symbol) => {\n Reflect.defineMetadata('swagger/apiModelProperties', false, target, key);\n };\n}\n"],"names":["registerEntities","Entity","TypeORMEntity","getMetadataArgsStorage","snakeCase","name","options","target","EntityFactory","model","storage","addEntity","addSwaggerDecorators","tables","some","el","Reflect","decorate","replace","Hide","key","defineMetadata"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,0BAA0B;AAC3D,SACEC,UAAUC,aAAa,EAEvBC,sBAAsB,QACjB,UAAU;AAEjB,SAASC,SAAS,QAAQ,8BAA8B;AAMxD;;;;;;;CAOC,GACD,6DAA6D;AAC7D,gFAAgF;AAChF,wCAAwC;AACxC,8DAA8D;AAC9D,wFAAwF;AACxF,+DAA+D;AAC/D,yDAAyD;AACzD,4FAA4F;AAC5F,2EAA2E;AAC3E,4EAA4E;AAC5E,sFAAsF;AACtF,gEAAgE;AAChE,qEAAqE;AACrE,OAAO,SAASH,OAAOI,IAAa,EAAEC,OAAuB;IAC3D,OAAO,CAACC;QACN,IAAIC,cAAcD,QAAQ;YAAEF;YAAM,GAAGC,OAAO;QAAC;IAC/C;AACF;AAEA,IAAA,AAAME,gBAAN,MAAMA;IAMJ,YACE,AAAQC,KAAe,EACvB,AAAQH,OAAwB,CAChC;aAFQG,QAAAA;aACAH,UAAAA;QAPV;;GAEC,QACOI,UAA+BP;QAMrC,IAAI,CAACQ,SAAS;QACd,IAAI,CAACC,oBAAoB;IAC3B;IAEA;;GAEC,GACDD,YAAY;QACV,yDAAyD;QACzD,IAAI,CAAC,IAAI,CAACD,OAAO,CAACG,MAAM,CAACC,IAAI,CAAC,CAACC,KAAOA,GAAGR,MAAM,KAAK,IAAI,CAACE,KAAK,GAAG;YAC/DO,QAAQC,QAAQ,CACd;gBACEf,cACE,IAAI,CAACI,OAAO,EAAED,QACZ,8BAA8B;gBAC9BD,UACE,IAAI,CAACK,KAAK,CAACJ,IAAI,CAACa,OAAO,CAAC,wBAAwB,MAAM,MAE1D,IAAI,CAACZ,OAAO;aAEf,EACD,IAAI,CAACG,KAAK;QAEd;IACF;IAEA;;GAEC,GACDG,uBAAuB;QACrB,4DAA4D;QAC5DZ,iBAAiB;YAAC,IAAI,CAACS,KAAK;SAAC;IAC/B;AACF;AAEA;;;;;CAKC,GACD,OAAO,SAASU;IACd,OAAO,CAACZ,QAAgBa;QACtBJ,QAAQK,cAAc,CAAC,8BAA8B,OAAOd,QAAQa;IACtE;AACF"}
|
|
@@ -1,56 +1,97 @@
|
|
|
1
|
-
/* eslint unicorn/prevent-abbreviations: 0 */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
/* eslint unicorn/prevent-abbreviations: 0 */ import { BadRequestException, Body, Param, Query, createParamDecorator } from "@nestjs/common";
|
|
2
|
+
import { ParseUUIDPipe } from "@nestjs/common";
|
|
3
|
+
import { ApiParam } from "@nestjs/swagger";
|
|
4
|
+
import { Payload } from "@nestjs/microservices";
|
|
5
|
+
import { MessageBody } from "@nestjs/websockets";
|
|
6
|
+
/**
|
|
7
|
+
* a param decorator that extracts a field from the request
|
|
8
|
+
* and validates it using pipes
|
|
9
|
+
* and add the suitable Swagger's docs
|
|
10
|
+
*
|
|
11
|
+
* @param name the field's name
|
|
12
|
+
* @param scope the scope where the prop is defined in
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* extract userId from params
|
|
16
|
+
* ```
|
|
17
|
+
* @Get(':userId')
|
|
18
|
+
* findUserById(@Prop('userId') userId: string){
|
|
19
|
+
* this.service.findUserById(userId);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* extract the id from the query string
|
|
25
|
+
* ```
|
|
26
|
+
* @Get()
|
|
27
|
+
* filterByTenant(@Prop('tenantId', 'query') tenantId: string){ ... }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* extract the product id from the request's body
|
|
32
|
+
* ```
|
|
33
|
+
* @Post()
|
|
34
|
+
* createOrder(@Prop('productId','body') productId: string){ ... }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* manipulate the swagger's docs: make the id optional
|
|
39
|
+
* ```
|
|
40
|
+
* @Get('id')
|
|
41
|
+
* find(@Prop('id', 'params', <any>{ required: false }) id?: string){
|
|
42
|
+
* return id?: this.service.findById(id) : this.service.find()
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @returns the field value
|
|
47
|
+
* @throws BadRequestException
|
|
48
|
+
*/ export function Prop(name, scope = 'params', pipes = []) {
|
|
27
49
|
return (target, propertyKey, parameterIndex)=>{
|
|
28
50
|
if (scope === 'payload') {
|
|
29
|
-
return
|
|
51
|
+
return Payload(name, ...pipes)(target, propertyKey, parameterIndex);
|
|
30
52
|
} else if (scope === 'messageBody') {
|
|
31
|
-
return
|
|
53
|
+
return MessageBody(name, ...pipes)(target, propertyKey, parameterIndex);
|
|
32
54
|
} else if (scope === 'params') {
|
|
33
|
-
return
|
|
55
|
+
return Param(name, ...pipes)(target, propertyKey, parameterIndex);
|
|
34
56
|
} else if (scope === 'query') {
|
|
35
|
-
return
|
|
57
|
+
return Query(name, ...pipes)(target, propertyKey, parameterIndex);
|
|
36
58
|
} else if (scope === 'body') {
|
|
37
|
-
return
|
|
59
|
+
return Body(name, ...pipes)(target, propertyKey, parameterIndex);
|
|
38
60
|
}
|
|
39
61
|
};
|
|
40
62
|
}
|
|
41
|
-
|
|
63
|
+
/**
|
|
64
|
+
* apply @prop() to extract the id field and validate its value as uuid *
|
|
65
|
+
* to customize the Swagger's docs use uuidApi()
|
|
66
|
+
* @returns the UUID value
|
|
67
|
+
* @throws BadRequestException
|
|
68
|
+
*/ export function Uuid(name = 'id', scope = 'params', pipes) {
|
|
42
69
|
return Prop(name, scope, pipes || [
|
|
43
|
-
new
|
|
70
|
+
new ParseUUIDPipe()
|
|
44
71
|
]);
|
|
45
72
|
}
|
|
46
|
-
|
|
73
|
+
/**
|
|
74
|
+
* same as Uuid() but can provide additional options for Swagger's docs
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* if the prop name is id, it is optional
|
|
78
|
+
* ```
|
|
79
|
+
* @Get('id)
|
|
80
|
+
* findById(@Uuid() id: string){}
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param name
|
|
84
|
+
* @param scope
|
|
85
|
+
* @param apiOptions additional options for swagger's docs
|
|
86
|
+
* @returns
|
|
87
|
+
*/ export function UuidApi(name = 'id', scope = 'params', // TODO: accept options based on the scope's value
|
|
47
88
|
// TODO: allow swapping between scope and apiOptions
|
|
48
89
|
apiOptions) {
|
|
49
90
|
return (target, propertyKey, parameterIndex)=>{
|
|
50
91
|
// TODO: add swagger docs for other scopes
|
|
51
92
|
// TODO: auto detect if the property is optional -> `@Uuid() id?: string`
|
|
52
93
|
if (scope === 'params') {
|
|
53
|
-
|
|
94
|
+
ApiParam({
|
|
54
95
|
name,
|
|
55
96
|
type: 'string',
|
|
56
97
|
format: 'uuid',
|
|
@@ -58,13 +99,13 @@ apiOptions) {
|
|
|
58
99
|
...apiOptions
|
|
59
100
|
})(target.constructor, propertyKey, Object.getOwnPropertyDescriptor(target, propertyKey));
|
|
60
101
|
}
|
|
61
|
-
let IdParamDecorator =
|
|
102
|
+
let IdParamDecorator = createParamDecorator((opts, ctx)=>{
|
|
62
103
|
let { name = 'id', scope = 'params' } = opts;
|
|
63
104
|
let req = ctx.switchToHttp().getRequest();
|
|
64
105
|
let id = req[scope][name];
|
|
65
|
-
if (!id) throw new
|
|
106
|
+
if (!id) throw new BadRequestException(`${name} is required`);
|
|
66
107
|
// Use ParseUUIDPipe to validate the UUID
|
|
67
|
-
let parseUUIDPipe = new
|
|
108
|
+
let parseUUIDPipe = new ParseUUIDPipe();
|
|
68
109
|
return parseUUIDPipe.transform(id, {
|
|
69
110
|
type: 'param',
|
|
70
111
|
metatype: String
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/decorators/prop.decorator.ts"],"sourcesContent":["/* eslint unicorn/prevent-abbreviations: 0 */\nimport {\n BadRequestException,\n Body,\n type ExecutionContext,\n Param,\n type PipeTransform,\n Query,\n type Type,\n createParamDecorator,\n} from '@nestjs/common';\nimport { ParseUUIDPipe } from '@nestjs/common';\nimport { ApiParam, type ApiParamOptions } from '@nestjs/swagger';\nimport { Payload } from '@nestjs/microservices';\nimport { MessageBody } from '@nestjs/websockets';\n\nexport interface IdParamDecoratorOptions {\n /**\n * The property that is wanted to be extracted\n */\n name?: string;\n /**\n * The scope to extract the property from\n * @example @Params('id')\n * @example @Payload('id')\n */\n scope?: 'params' | 'query' | 'body' | 'payload' | 'messageBody';\n}\n\n/**\n * a param decorator that extracts a field from the request\n * and validates it using pipes\n * and add the suitable Swagger's docs\n *\n * @param name the field's name\n * @param scope the scope where the prop is defined in\n *\n * @example\n * extract userId from params\n * ```\n * @Get(':userId')\n * findUserById(@Prop('userId') userId: string){\n * this.service.findUserById(userId);\n * }\n * ```\n *\n * @example\n * extract the id from the query string\n * ```\n * @Get()\n * filterByTenant(@Prop('tenantId', 'query') tenantId: string){ ... }\n * ```\n *\n * @example\n * extract the product id from the request's body\n * ```\n * @Post()\n * createOrder(@Prop('productId','body') productId: string){ ... }\n * ```\n *\n * @example\n * manipulate the swagger's docs: make the id optional\n * ```\n * @Get('id')\n * find(@Prop('id', 'params', <any>{ required: false }) id?: string){\n * return id?: this.service.findById(id) : this.service.find()\n * }\n * ```\n *\n * @returns the field value\n * @throws BadRequestException\n */\nexport function Prop(\n name: string,\n scope: IdParamDecoratorOptions['scope'] = 'params',\n pipes: (Type<PipeTransform> | PipeTransform)[] = [],\n): ParameterDecorator {\n return (\n target: Object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ) => {\n if (scope === 'payload') {\n return Payload(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'messageBody') {\n return MessageBody(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'params') {\n return Param(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'query') {\n return Query(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'body') {\n return Body(name, ...pipes)(target, propertyKey, parameterIndex);\n }\n };\n}\n\n/**\n * apply @prop() to extract the id field and validate its value as uuid *\n * to customize the Swagger's docs use uuidApi()\n * @returns the UUID value\n * @throws BadRequestException\n */\nexport function Uuid(\n name = 'id',\n scope: IdParamDecoratorOptions['scope'] = 'params',\n pipes?: (Type<PipeTransform> | PipeTransform)[],\n): ParameterDecorator {\n return Prop(name, scope, pipes || [new ParseUUIDPipe()]);\n}\n\n/**\n * same as Uuid() but can provide additional options for Swagger's docs\n *\n * @example\n * if the prop name is id, it is optional\n * ```\n * @Get('id)\n * findById(@Uuid() id: string){}\n * ```\n *\n * @param name\n * @param scope\n * @param apiOptions additional options for swagger's docs\n * @returns\n */\nexport function UuidApi(\n name = 'id',\n scope: IdParamDecoratorOptions['scope'] = 'params',\n // TODO: accept options based on the scope's value\n // TODO: allow swapping between scope and apiOptions\n apiOptions?: ApiParamOptions,\n): ParameterDecorator {\n return (\n target: Object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ) => {\n // TODO: add swagger docs for other scopes\n // TODO: auto detect if the property is optional -> `@Uuid() id?: string`\n if (scope === 'params') {\n ApiParam({\n name,\n type: 'string',\n format: 'uuid',\n example: '4eae7b32-9065-42b0-a025-5cb967011e65',\n ...apiOptions,\n })(\n target.constructor,\n propertyKey as string,\n Object.getOwnPropertyDescriptor(target, propertyKey!)!,\n );\n }\n\n let IdParamDecorator = createParamDecorator(\n (opts: IdParamDecoratorOptions, ctx: ExecutionContext) => {\n let { name = 'id', scope = 'params' } = opts;\n\n let req = ctx.switchToHttp().getRequest();\n let id = req[scope][name];\n\n if (!id) throw new BadRequestException(`${name} is required`);\n\n // Use ParseUUIDPipe to validate the UUID\n let parseUUIDPipe = new ParseUUIDPipe();\n return parseUUIDPipe.transform(id, {\n type: 'param',\n metatype: String,\n });\n },\n );\n\n return IdParamDecorator({ name, scope })(\n target,\n propertyKey,\n parameterIndex,\n );\n };\n}\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../src/decorators/prop.decorator.ts"],"sourcesContent":["/* eslint unicorn/prevent-abbreviations: 0 */\nimport {\n BadRequestException,\n Body,\n type ExecutionContext,\n Param,\n type PipeTransform,\n Query,\n type Type,\n createParamDecorator,\n} from '@nestjs/common';\nimport { ParseUUIDPipe } from '@nestjs/common';\nimport { ApiParam, type ApiParamOptions } from '@nestjs/swagger';\nimport { Payload } from '@nestjs/microservices';\nimport { MessageBody } from '@nestjs/websockets';\n\nexport interface IdParamDecoratorOptions {\n /**\n * The property that is wanted to be extracted\n */\n name?: string;\n /**\n * The scope to extract the property from\n * @example @Params('id')\n * @example @Payload('id')\n */\n scope?: 'params' | 'query' | 'body' | 'payload' | 'messageBody';\n}\n\n/**\n * a param decorator that extracts a field from the request\n * and validates it using pipes\n * and add the suitable Swagger's docs\n *\n * @param name the field's name\n * @param scope the scope where the prop is defined in\n *\n * @example\n * extract userId from params\n * ```\n * @Get(':userId')\n * findUserById(@Prop('userId') userId: string){\n * this.service.findUserById(userId);\n * }\n * ```\n *\n * @example\n * extract the id from the query string\n * ```\n * @Get()\n * filterByTenant(@Prop('tenantId', 'query') tenantId: string){ ... }\n * ```\n *\n * @example\n * extract the product id from the request's body\n * ```\n * @Post()\n * createOrder(@Prop('productId','body') productId: string){ ... }\n * ```\n *\n * @example\n * manipulate the swagger's docs: make the id optional\n * ```\n * @Get('id')\n * find(@Prop('id', 'params', <any>{ required: false }) id?: string){\n * return id?: this.service.findById(id) : this.service.find()\n * }\n * ```\n *\n * @returns the field value\n * @throws BadRequestException\n */\nexport function Prop(\n name: string,\n scope: IdParamDecoratorOptions['scope'] = 'params',\n pipes: (Type<PipeTransform> | PipeTransform)[] = [],\n): ParameterDecorator {\n return (\n target: Object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ) => {\n if (scope === 'payload') {\n return Payload(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'messageBody') {\n return MessageBody(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'params') {\n return Param(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'query') {\n return Query(name, ...pipes)(target, propertyKey, parameterIndex);\n } else if (scope === 'body') {\n return Body(name, ...pipes)(target, propertyKey, parameterIndex);\n }\n };\n}\n\n/**\n * apply @prop() to extract the id field and validate its value as uuid *\n * to customize the Swagger's docs use uuidApi()\n * @returns the UUID value\n * @throws BadRequestException\n */\nexport function Uuid(\n name = 'id',\n scope: IdParamDecoratorOptions['scope'] = 'params',\n pipes?: (Type<PipeTransform> | PipeTransform)[],\n): ParameterDecorator {\n return Prop(name, scope, pipes || [new ParseUUIDPipe()]);\n}\n\n/**\n * same as Uuid() but can provide additional options for Swagger's docs\n *\n * @example\n * if the prop name is id, it is optional\n * ```\n * @Get('id)\n * findById(@Uuid() id: string){}\n * ```\n *\n * @param name\n * @param scope\n * @param apiOptions additional options for swagger's docs\n * @returns\n */\nexport function UuidApi(\n name = 'id',\n scope: IdParamDecoratorOptions['scope'] = 'params',\n // TODO: accept options based on the scope's value\n // TODO: allow swapping between scope and apiOptions\n apiOptions?: ApiParamOptions,\n): ParameterDecorator {\n return (\n target: Object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ) => {\n // TODO: add swagger docs for other scopes\n // TODO: auto detect if the property is optional -> `@Uuid() id?: string`\n if (scope === 'params') {\n ApiParam({\n name,\n type: 'string',\n format: 'uuid',\n example: '4eae7b32-9065-42b0-a025-5cb967011e65',\n ...apiOptions,\n })(\n target.constructor,\n propertyKey as string,\n Object.getOwnPropertyDescriptor(target, propertyKey!)!,\n );\n }\n\n let IdParamDecorator = createParamDecorator(\n (opts: IdParamDecoratorOptions, ctx: ExecutionContext) => {\n let { name = 'id', scope = 'params' } = opts;\n\n let req = ctx.switchToHttp().getRequest();\n let id = req[scope][name];\n\n if (!id) throw new BadRequestException(`${name} is required`);\n\n // Use ParseUUIDPipe to validate the UUID\n let parseUUIDPipe = new ParseUUIDPipe();\n return parseUUIDPipe.transform(id, {\n type: 'param',\n metatype: String,\n });\n },\n );\n\n return IdParamDecorator({ name, scope })(\n target,\n propertyKey,\n parameterIndex,\n );\n };\n}\n"],"names":["BadRequestException","Body","Param","Query","createParamDecorator","ParseUUIDPipe","ApiParam","Payload","MessageBody","Prop","name","scope","pipes","target","propertyKey","parameterIndex","Uuid","UuidApi","apiOptions","type","format","example","Object","getOwnPropertyDescriptor","IdParamDecorator","opts","ctx","req","switchToHttp","getRequest","id","parseUUIDPipe","transform","metatype","String"],"mappings":"AAAA,2CAA2C,GAC3C,SACEA,mBAAmB,EACnBC,IAAI,EAEJC,KAAK,EAELC,KAAK,EAELC,oBAAoB,QACf,iBAAiB;AACxB,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,QAAQ,QAA8B,kBAAkB;AACjE,SAASC,OAAO,QAAQ,wBAAwB;AAChD,SAASC,WAAW,QAAQ,qBAAqB;AAejD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CC,GACD,OAAO,SAASC,KACdC,IAAY,EACZC,QAA0C,QAAQ,EAClDC,QAAiD,EAAE;IAEnD,OAAO,CACLC,QACAC,aACAC;QAEA,IAAIJ,UAAU,WAAW;YACvB,OAAOJ,QAAQG,SAASE,OAAOC,QAAQC,aAAaC;QACtD,OAAO,IAAIJ,UAAU,eAAe;YAClC,OAAOH,YAAYE,SAASE,OAAOC,QAAQC,aAAaC;QAC1D,OAAO,IAAIJ,UAAU,UAAU;YAC7B,OAAOT,MAAMQ,SAASE,OAAOC,QAAQC,aAAaC;QACpD,OAAO,IAAIJ,UAAU,SAAS;YAC5B,OAAOR,MAAMO,SAASE,OAAOC,QAAQC,aAAaC;QACpD,OAAO,IAAIJ,UAAU,QAAQ;YAC3B,OAAOV,KAAKS,SAASE,OAAOC,QAAQC,aAAaC;QACnD;IACF;AACF;AAEA;;;;;CAKC,GACD,OAAO,SAASC,KACdN,OAAO,IAAI,EACXC,QAA0C,QAAQ,EAClDC,KAA+C;IAE/C,OAAOH,KAAKC,MAAMC,OAAOC,SAAS;QAAC,IAAIP;KAAgB;AACzD;AAEA;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASY,QACdP,OAAO,IAAI,EACXC,QAA0C,QAAQ,EAClD,kDAAkD;AAClD,oDAAoD;AACpDO,UAA4B;IAE5B,OAAO,CACLL,QACAC,aACAC;QAEA,0CAA0C;QAC1C,yEAAyE;QACzE,IAAIJ,UAAU,UAAU;YACtBL,SAAS;gBACPI;gBACAS,MAAM;gBACNC,QAAQ;gBACRC,SAAS;gBACT,GAAGH,UAAU;YACf,GACEL,OAAO,WAAW,EAClBC,aACAQ,OAAOC,wBAAwB,CAACV,QAAQC;QAE5C;QAEA,IAAIU,mBAAmBpB,qBACrB,CAACqB,MAA+BC;YAC9B,IAAI,EAAEhB,OAAO,IAAI,EAAEC,QAAQ,QAAQ,EAAE,GAAGc;YAExC,IAAIE,MAAMD,IAAIE,YAAY,GAAGC,UAAU;YACvC,IAAIC,KAAKH,GAAG,CAAChB,MAAM,CAACD,KAAK;YAEzB,IAAI,CAACoB,IAAI,MAAM,IAAI9B,oBAAoB,GAAGU,KAAK,YAAY,CAAC;YAE5D,yCAAyC;YACzC,IAAIqB,gBAAgB,IAAI1B;YACxB,OAAO0B,cAAcC,SAAS,CAACF,IAAI;gBACjCX,MAAM;gBACNc,UAAUC;YACZ;QACF;QAGF,OAAOV,iBAAiB;YAAEd;YAAMC;QAAM,GACpCE,QACAC,aACAC;IAEJ;AACF"}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "RpcBadRequestException", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return RpcBadRequestException;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _common = require("@nestjs/common");
|
|
12
|
-
const _rpcbaseexception = require("./rpc-base.exception");
|
|
13
|
-
let RpcBadRequestException = class RpcBadRequestException extends _rpcbaseexception.RpcBaseException {
|
|
1
|
+
import { HttpStatus } from "@nestjs/common";
|
|
2
|
+
import { RpcBaseException } from "./rpc-base.exception.js";
|
|
3
|
+
export class RpcBadRequestException extends RpcBaseException {
|
|
14
4
|
constructor(message = 'Bad request'){
|
|
15
|
-
super(message,
|
|
5
|
+
super(message, HttpStatus.BAD_REQUEST);
|
|
16
6
|
}
|
|
17
|
-
}
|
|
7
|
+
}
|
|
18
8
|
|
|
19
9
|
//# sourceMappingURL=rpc-bad-request.exception.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/exceptions/rpc-bad-request.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcBadRequestException extends RpcBaseException {\n constructor(message = 'Bad request') {\n super(message, HttpStatus.BAD_REQUEST);\n }\n}\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions/rpc-bad-request.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception.js';\n\nexport class RpcBadRequestException extends RpcBaseException {\n constructor(message = 'Bad request') {\n super(message, HttpStatus.BAD_REQUEST);\n }\n}\n"],"names":["HttpStatus","RpcBaseException","RpcBadRequestException","message","BAD_REQUEST"],"mappings":"AAAA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,gBAAgB,QAAQ,0BAA0B;AAE3D,OAAO,MAAMC,+BAA+BD;IAC1C,YAAYE,UAAU,aAAa,CAAE;QACnC,KAAK,CAACA,SAASH,WAAWI,WAAW;IACvC;AACF"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
const _microservices = require("@nestjs/microservices");
|
|
12
|
-
const _common = require("@nestjs/common");
|
|
13
|
-
let RpcBaseException = class RpcBaseException extends _microservices.RpcException {
|
|
14
|
-
constructor(message, statusCode = _common.HttpStatus.INTERNAL_SERVER_ERROR){
|
|
1
|
+
import { RpcException } from "@nestjs/microservices";
|
|
2
|
+
import { HttpStatus } from "@nestjs/common";
|
|
3
|
+
/**
|
|
4
|
+
* Base Error class for RPC exceptions.
|
|
5
|
+
* This exception resembles the behavior of HTTP exceptions, but for RPC errors.
|
|
6
|
+
*/ // todo: use `RpcException(new BadRequestException(message))` instead of creating custom RPC exceptions
|
|
7
|
+
// https://stackoverflow.com/a/75335979
|
|
8
|
+
export class RpcBaseException extends RpcException {
|
|
9
|
+
constructor(message, statusCode = HttpStatus.INTERNAL_SERVER_ERROR){
|
|
15
10
|
super({
|
|
16
11
|
message
|
|
17
12
|
});
|
|
18
13
|
this.statusCode = statusCode;
|
|
19
14
|
}
|
|
20
|
-
}
|
|
15
|
+
}
|
|
21
16
|
|
|
22
17
|
//# sourceMappingURL=rpc-base.exception.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/exceptions/rpc-base.exception.ts"],"sourcesContent":["import { RpcException } from '@nestjs/microservices';\nimport { HttpStatus } from '@nestjs/common';\n\n/**\n * Base Error class for RPC exceptions.\n * This exception resembles the behavior of HTTP exceptions, but for RPC errors.\n */\n// todo: use `RpcException(new BadRequestException(message))` instead of creating custom RPC exceptions\n// https://stackoverflow.com/a/75335979\nexport class RpcBaseException extends RpcException {\n statusCode: HttpStatus;\n\n constructor(\n message: string,\n statusCode: HttpStatus = HttpStatus.INTERNAL_SERVER_ERROR,\n ) {\n super({ message });\n this.statusCode = statusCode;\n }\n}\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions/rpc-base.exception.ts"],"sourcesContent":["import { RpcException } from '@nestjs/microservices';\nimport { HttpStatus } from '@nestjs/common';\n\n/**\n * Base Error class for RPC exceptions.\n * This exception resembles the behavior of HTTP exceptions, but for RPC errors.\n */\n// todo: use `RpcException(new BadRequestException(message))` instead of creating custom RPC exceptions\n// https://stackoverflow.com/a/75335979\nexport class RpcBaseException extends RpcException {\n statusCode: HttpStatus;\n\n constructor(\n message: string,\n statusCode: HttpStatus = HttpStatus.INTERNAL_SERVER_ERROR,\n ) {\n super({ message });\n this.statusCode = statusCode;\n }\n}\n"],"names":["RpcException","HttpStatus","RpcBaseException","message","statusCode","INTERNAL_SERVER_ERROR"],"mappings":"AAAA,SAASA,YAAY,QAAQ,wBAAwB;AACrD,SAASC,UAAU,QAAQ,iBAAiB;AAE5C;;;CAGC,GACD,uGAAuG;AACvG,uCAAuC;AACvC,OAAO,MAAMC,yBAAyBF;IAGpC,YACEG,OAAe,EACfC,aAAyBH,WAAWI,qBAAqB,CACzD;QACA,KAAK,CAAC;YAAEF;QAAQ;QAChB,IAAI,CAACC,UAAU,GAAGA;IACpB;AACF"}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "RpcConflictException", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return RpcConflictException;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _common = require("@nestjs/common");
|
|
12
|
-
const _rpcbaseexception = require("./rpc-base.exception");
|
|
13
|
-
let RpcConflictException = class RpcConflictException extends _rpcbaseexception.RpcBaseException {
|
|
1
|
+
import { HttpStatus } from "@nestjs/common";
|
|
2
|
+
import { RpcBaseException } from "./rpc-base.exception.js";
|
|
3
|
+
export class RpcConflictException extends RpcBaseException {
|
|
14
4
|
constructor(message = 'Conflict'){
|
|
15
|
-
super(message,
|
|
5
|
+
super(message, HttpStatus.CONFLICT);
|
|
16
6
|
}
|
|
17
|
-
}
|
|
7
|
+
}
|
|
18
8
|
|
|
19
9
|
//# sourceMappingURL=rpc-conflict.exception.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/exceptions/rpc-conflict.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcConflictException extends RpcBaseException {\n constructor(message = 'Conflict') {\n super(message, HttpStatus.CONFLICT);\n }\n}\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions/rpc-conflict.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception.js';\n\nexport class RpcConflictException extends RpcBaseException {\n constructor(message = 'Conflict') {\n super(message, HttpStatus.CONFLICT);\n }\n}\n"],"names":["HttpStatus","RpcBaseException","RpcConflictException","message","CONFLICT"],"mappings":"AAAA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,gBAAgB,QAAQ,0BAA0B;AAE3D,OAAO,MAAMC,6BAA6BD;IACxC,YAAYE,UAAU,UAAU,CAAE;QAChC,KAAK,CAACA,SAASH,WAAWI,QAAQ;IACpC;AACF"}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "RpcInternalServerErrorException", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return RpcInternalServerErrorException;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _common = require("@nestjs/common");
|
|
12
|
-
const _rpcbaseexception = require("./rpc-base.exception");
|
|
13
|
-
let RpcInternalServerErrorException = class RpcInternalServerErrorException extends _rpcbaseexception.RpcBaseException {
|
|
1
|
+
import { HttpStatus } from "@nestjs/common";
|
|
2
|
+
import { RpcBaseException } from "./rpc-base.exception.js";
|
|
3
|
+
export class RpcInternalServerErrorException extends RpcBaseException {
|
|
14
4
|
constructor(message = 'Internal server error'){
|
|
15
|
-
super(message,
|
|
5
|
+
super(message, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
16
6
|
}
|
|
17
|
-
}
|
|
7
|
+
}
|
|
18
8
|
|
|
19
9
|
//# sourceMappingURL=rpc-internal-server-error.exception.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/exceptions/rpc-internal-server-error.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcInternalServerErrorException extends RpcBaseException {\n constructor(message = 'Internal server error') {\n super(message, HttpStatus.INTERNAL_SERVER_ERROR);\n }\n}\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions/rpc-internal-server-error.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception.js';\n\nexport class RpcInternalServerErrorException extends RpcBaseException {\n constructor(message = 'Internal server error') {\n super(message, HttpStatus.INTERNAL_SERVER_ERROR);\n }\n}\n"],"names":["HttpStatus","RpcBaseException","RpcInternalServerErrorException","message","INTERNAL_SERVER_ERROR"],"mappings":"AAAA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,gBAAgB,QAAQ,0BAA0B;AAE3D,OAAO,MAAMC,wCAAwCD;IACnD,YAAYE,UAAU,uBAAuB,CAAE;QAC7C,KAAK,CAACA,SAASH,WAAWI,qBAAqB;IACjD;AACF"}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "RpcMethodNotAllowedException", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return RpcMethodNotAllowedException;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _common = require("@nestjs/common");
|
|
12
|
-
const _rpcbaseexception = require("./rpc-base.exception");
|
|
13
|
-
let RpcMethodNotAllowedException = class RpcMethodNotAllowedException extends _rpcbaseexception.RpcBaseException {
|
|
1
|
+
import { HttpStatus } from "@nestjs/common";
|
|
2
|
+
import { RpcBaseException } from "./rpc-base.exception.js";
|
|
3
|
+
export class RpcMethodNotAllowedException extends RpcBaseException {
|
|
14
4
|
constructor(message = 'Method not allowed'){
|
|
15
|
-
super(message,
|
|
5
|
+
super(message, HttpStatus.METHOD_NOT_ALLOWED);
|
|
16
6
|
}
|
|
17
|
-
}
|
|
7
|
+
}
|
|
18
8
|
|
|
19
9
|
//# sourceMappingURL=rpc-method-not-allowed.exception.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/exceptions/rpc-method-not-allowed.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcMethodNotAllowedException extends RpcBaseException {\n constructor(message = 'Method not allowed') {\n super(message, HttpStatus.METHOD_NOT_ALLOWED);\n }\n}\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions/rpc-method-not-allowed.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception.js';\n\nexport class RpcMethodNotAllowedException extends RpcBaseException {\n constructor(message = 'Method not allowed') {\n super(message, HttpStatus.METHOD_NOT_ALLOWED);\n }\n}\n"],"names":["HttpStatus","RpcBaseException","RpcMethodNotAllowedException","message","METHOD_NOT_ALLOWED"],"mappings":"AAAA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,gBAAgB,QAAQ,0BAA0B;AAE3D,OAAO,MAAMC,qCAAqCD;IAChD,YAAYE,UAAU,oBAAoB,CAAE;QAC1C,KAAK,CAACA,SAASH,WAAWI,kBAAkB;IAC9C;AACF"}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "RpcNotFoundException", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return RpcNotFoundException;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _common = require("@nestjs/common");
|
|
12
|
-
const _rpcbaseexception = require("./rpc-base.exception");
|
|
13
|
-
let RpcNotFoundException = class RpcNotFoundException extends _rpcbaseexception.RpcBaseException {
|
|
1
|
+
import { HttpStatus } from "@nestjs/common";
|
|
2
|
+
import { RpcBaseException } from "./rpc-base.exception.js";
|
|
3
|
+
export class RpcNotFoundException extends RpcBaseException {
|
|
14
4
|
constructor(message = 'Not Found'){
|
|
15
|
-
super(message,
|
|
5
|
+
super(message, HttpStatus.NOT_FOUND);
|
|
16
6
|
}
|
|
17
|
-
}
|
|
7
|
+
}
|
|
18
8
|
|
|
19
9
|
//# sourceMappingURL=rpc-not-found.exception.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/exceptions/rpc-not-found.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception';\n\nexport class RpcNotFoundException extends RpcBaseException {\n constructor(message = 'Not Found') {\n super(message, HttpStatus.NOT_FOUND);\n }\n}\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../src/exceptions/rpc-not-found.exception.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\nimport { RpcBaseException } from './rpc-base.exception.js';\n\nexport class RpcNotFoundException extends RpcBaseException {\n constructor(message = 'Not Found') {\n super(message, HttpStatus.NOT_FOUND);\n }\n}\n"],"names":["HttpStatus","RpcBaseException","RpcNotFoundException","message","NOT_FOUND"],"mappings":"AAAA,SAASA,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,gBAAgB,QAAQ,0BAA0B;AAE3D,OAAO,MAAMC,6BAA6BD;IACxC,YAAYE,UAAU,WAAW,CAAE;QACjC,KAAK,CAACA,SAASH,WAAWI,SAAS;IACrC;AACF"}
|