@nest-extended/core 0.0.1-beta-10 → 0.0.2-beta-1

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/README.md CHANGED
@@ -5,11 +5,10 @@ This package provides the core building blocks for NestJS applications built wit
5
5
  ## Key Features
6
6
 
7
7
  - **Generic Controller (`NestController`)**: A base controller class that handles common CRUD operations (`find`, `get`, `create`, `patch`, `delete`) by delegating to a service implementing `ServiceOptions`.
8
- - **Decorators**:
9
- - `@User()`: Retrieves the current user from the request (integrates with `nestjs-cls` or request object).
10
- - `@Public()`: Marks a route as public (useful for authentication guards).
11
- - `@ModifyBody()`: Allows modification of the request body before validation (e.g., setting `createdBy`).
12
- - **Configuration**: Interfaces for configuring soft delete behavior and other service options.
8
+ - **Decorators**: Moved to `@nest-extended/decorators`.
9
+ - `@User()`
10
+ - `@Public()`
11
+ - `@ModifyBody()`
13
12
 
14
13
  ## Usage
15
14
 
@@ -31,16 +30,8 @@ export class MyController extends NestController<MyResource> {
31
30
 
32
31
  ### Decorators
33
32
 
34
- ```typescript
35
- import { User, Public, ModifyBody, setCreatedBy } from '@nest-extended/core';
36
-
37
- @Public()
38
- @Get()
39
- findAll() { ... }
33
+ Decorators have been moved to their own package.
40
34
 
41
- @Post()
42
- create(@ModifyBody(setCreatedBy()) body: CreateDto) { ... }
43
-
44
- @Get('profile')
45
- getProfile(@User() user: any) { ... }
35
+ ```typescript
36
+ import { User, Public, ModifyBody, setCreatedBy } from '@nest-extended/decorators';
46
37
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-extended/core",
3
- "version": "0.0.1-beta-10",
3
+ "version": "0.0.2-beta-1",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
package/src/index.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  export * from './lib/nest.controller';
2
2
  export * from './lib/nest-extended.module';
3
3
  export { default as options } from './common/options';
4
- export * from './common/decorators/ModifyBody.decorator';
5
- export * from './common/decorators/Public.decorator';
6
- export * from './common/decorators/User.decorator';
7
4
  export * from './common/cls.helper';
8
5
  export * from './types/nest-extended.config';
9
6
  export * from './types/PaginatedResponse';
package/src/index.js CHANGED
@@ -6,9 +6,6 @@ tslib_1.__exportStar(require("./lib/nest.controller"), exports);
6
6
  tslib_1.__exportStar(require("./lib/nest-extended.module"), exports);
7
7
  var options_1 = require("./common/options");
8
8
  Object.defineProperty(exports, "options", { enumerable: true, get: function () { return options_1.default; } });
9
- tslib_1.__exportStar(require("./common/decorators/ModifyBody.decorator"), exports);
10
- tslib_1.__exportStar(require("./common/decorators/Public.decorator"), exports);
11
- tslib_1.__exportStar(require("./common/decorators/User.decorator"), exports);
12
9
  tslib_1.__exportStar(require("./common/cls.helper"), exports);
13
10
  tslib_1.__exportStar(require("./types/nest-extended.config"), exports);
14
11
  tslib_1.__exportStar(require("./types/PaginatedResponse"), exports);
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;;AAAA,gEAAsC;AACtC,qEAA2C;AAC3C,4CAAsD;AAA7C,kGAAA,OAAO,OAAW;AAC3B,mFAAyD;AACzD,+EAAqD;AACrD,6EAAmD;AACnD,8DAAoC;AACpC,uEAA6C;AAC7C,oEAA0C;AAC1C,iEAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;;AAAA,gEAAsC;AACtC,qEAA2C;AAC3C,4CAAsD;AAA7C,kGAAA,OAAO,OAAW;AAC3B,8DAAoC;AACpC,uEAA6C;AAC7C,oEAA0C;AAC1C,iEAAuC"}
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NestController = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const common_1 = require("@nestjs/common");
6
- const Public_decorator_1 = require("../common/decorators/Public.decorator");
7
- const User_decorator_1 = require("../common/decorators/User.decorator");
8
- const ModifyBody_decorator_1 = require("../common/decorators/ModifyBody.decorator");
6
+ const decorators_1 = require("@nest-extended/decorators");
9
7
  class NestController {
10
8
  constructor(service) {
11
9
  this.service = service;
@@ -39,7 +37,7 @@ class NestController {
39
37
  }
40
38
  exports.NestController = NestController;
41
39
  tslib_1.__decorate([
42
- (0, Public_decorator_1.Public)(),
40
+ (0, decorators_1.Public)(),
43
41
  (0, common_1.Get)(),
44
42
  tslib_1.__param(0, (0, common_1.Query)()),
45
43
  tslib_1.__metadata("design:type", Function),
@@ -56,7 +54,7 @@ tslib_1.__decorate([
56
54
  ], NestController.prototype, "get", null);
57
55
  tslib_1.__decorate([
58
56
  (0, common_1.Post)(),
59
- tslib_1.__param(0, (0, ModifyBody_decorator_1.ModifyBody)((0, ModifyBody_decorator_1.setCreatedBy)())),
57
+ tslib_1.__param(0, (0, decorators_1.ModifyBody)((0, decorators_1.setCreatedBy)())),
60
58
  tslib_1.__metadata("design:type", Function),
61
59
  tslib_1.__metadata("design:paramtypes", [Object]),
62
60
  tslib_1.__metadata("design:returntype", Promise)
@@ -74,7 +72,7 @@ tslib_1.__decorate([
74
72
  (0, common_1.Delete)('/:id?'),
75
73
  tslib_1.__param(0, (0, common_1.Param)('id')),
76
74
  tslib_1.__param(1, (0, common_1.Query)()),
77
- tslib_1.__param(2, (0, User_decorator_1.User)()),
75
+ tslib_1.__param(2, (0, decorators_1.User)()),
78
76
  tslib_1.__metadata("design:type", Function),
79
77
  tslib_1.__metadata("design:paramtypes", [String, Object, Object]),
80
78
  tslib_1.__metadata("design:returntype", Promise)
@@ -1 +1 @@
1
- {"version":3,"file":"nest.controller.js","sourceRoot":"","sources":["../../../../../packages/core/src/lib/nest.controller.ts"],"names":[],"mappings":";;;;AAAA,2CASwB;AACxB,4EAA+D;AAC/D,wEAA2D;AAE3D,oFAAqF;AAErF,MAAa,cAAc;IAGvB,YAA6B,OAA0B;QAA1B,YAAO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EAAE,IAAI,CAAC,CAAC;QACvD,CAAC;KAAA;CACJ;AAtCD,wCAsCC;AA/BS;IAFL,IAAA,mBAAM,GAAE;IACR,IAAA,YAAG,GAAE;IACM,mBAAA,IAAA,cAAK,GAAE,CAAA;;;;0CAElB;AAGK;IADL,IAAA,YAAG,EAAC,OAAO,CAAC;IACF,mBAAA,IAAA,cAAK,GAAE,CAAA;IAA8B,mBAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;yCAE1D;AAGK;IADL,IAAA,aAAI,GAAE;IACO,mBAAA,IAAA,uBAAU,EAAC,IAAA,yBAAY,GAAE,CAAC,CAAA;;;;4CAEvC;AAGK;IADL,IAAA,cAAK,EAAC,OAAO,CAAC;IAEV,mBAAA,IAAA,cAAK,GAAE,CAAA;IACP,mBAAA,IAAA,aAAI,GAAE,CAAA;IACN,mBAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;2CAGf;AAGK;IADL,IAAA,eAAM,EAAC,OAAO,CAAC;IAEX,mBAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,mBAAA,IAAA,cAAK,GAAE,CAAA;IACP,mBAAA,IAAA,iBAAI,GAAE,CAAA;;;;4CAGV"}
@@ -1,8 +0,0 @@
1
- import { Request as ExRequest } from 'express-serve-static-core';
2
- declare type Request = {
3
- user: any;
4
- } & ExRequest;
5
- declare type ModifyBodyFn = (request: Request) => Request;
6
- export declare const setCreatedBy: (key?: string) => ModifyBodyFn;
7
- export declare const ModifyBody: (...dataOrPipes: (ModifyBodyFn | ModifyBodyFn[] | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>> | undefined)[]) => ParameterDecorator;
8
- export {};
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModifyBody = exports.setCreatedBy = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const setCreatedBy = (key = 'createdBy') => (request) => {
6
- request.body[key] = request.user._id;
7
- return request;
8
- };
9
- exports.setCreatedBy = setCreatedBy;
10
- exports.ModifyBody = (0, common_1.createParamDecorator)((fn, ctx) => {
11
- const request = ctx.switchToHttp().getRequest();
12
- if (Array.isArray(fn)) {
13
- fn.forEach((f) => f === null || f === void 0 ? void 0 : f(request));
14
- }
15
- else {
16
- fn === null || fn === void 0 ? void 0 : fn(request);
17
- }
18
- return request.body;
19
- });
20
- //# sourceMappingURL=ModifyBody.decorator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModifyBody.decorator.js","sourceRoot":"","sources":["../../../../../../packages/core/src/common/decorators/ModifyBody.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAUjE,MAAM,YAAY,GACrB,CAAC,GAAG,GAAG,WAAW,EAAgB,EAAE,CAChC,CAAC,OAAgB,EAAE,EAAE;IACjB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;IACrC,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AALG,QAAA,YAAY,gBAKf;AAEG,QAAA,UAAU,GAAG,IAAA,6BAAoB,EAC1C,CAAC,EAA6C,EAAE,GAAqB,EAAE,EAAE;IACrE,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QACpB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAG,OAAO,CAAC,CAAC,CAAC;IACpC,CAAC;SAAM,CAAC;QACJ,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAG,OAAO,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC;AACxB,CAAC,CACJ,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const IS_PUBLIC_KEY = "isPublic";
2
- export declare const Public: () => import("@nestjs/common").CustomDecorator<string>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Public = exports.IS_PUBLIC_KEY = void 0;
4
- const common_1 = require("@nestjs/common");
5
- exports.IS_PUBLIC_KEY = 'isPublic';
6
- const Public = () => (0, common_1.SetMetadata)(exports.IS_PUBLIC_KEY, true);
7
- exports.Public = Public;
8
- //# sourceMappingURL=Public.decorator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Public.decorator.js","sourceRoot":"","sources":["../../../../../../packages/core/src/common/decorators/Public.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAEhC,QAAA,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,qBAAa,EAAE,IAAI,CAAC,CAAC;AAAhD,QAAA,MAAM,UAA0C"}
@@ -1 +0,0 @@
1
- export declare const User: (...dataOrPipes: unknown[]) => ParameterDecorator;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.User = void 0;
4
- const common_1 = require("@nestjs/common");
5
- exports.User = (0, common_1.createParamDecorator)((data, ctx) => {
6
- const request = ctx.switchToHttp().getRequest();
7
- return request.user;
8
- });
9
- //# sourceMappingURL=User.decorator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"User.decorator.js","sourceRoot":"","sources":["../../../../../../packages/core/src/common/decorators/User.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAE3D,QAAA,IAAI,GAAG,IAAA,6BAAoB,EACpC,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IACrC,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,IAAI,CAAC;AACxB,CAAC,CACJ,CAAC"}