mongodb-dynamic-api 1.3.0 → 1.3.2
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/CHANGELOG.md +4 -0
- package/README.md +114 -18
- package/package.json +3 -1
- package/src/dynamic-api.module.d.ts +4 -3
- package/src/dynamic-api.module.js +16 -1
- package/src/interfaces/controller-options.interface.d.ts +8 -0
- package/src/interfaces/dynamic-api-cache-options.interface.d.ts +8 -0
- package/src/interfaces/dynamic-api-options.interface.d.ts +10 -10
- package/src/interfaces/{route-config.interface.d.ts → dynamic-api-route-config.interface.d.ts} +2 -2
- package/src/interfaces/dynamic-api-route-config.interface.js +2 -0
- package/src/interfaces/{service-provider.interface.d.ts → dynamic-api-service-provider.interface.d.ts} +2 -2
- package/src/interfaces/dynamic-api-service-provider.interface.js +2 -0
- package/src/interfaces/index.d.ts +4 -3
- package/src/interfaces/index.js +4 -3
- package/src/modules/create-many/create-many.helper.d.ts +2 -2
- package/src/modules/create-many/create-many.module.d.ts +2 -2
- package/src/modules/create-one/create-one.helper.d.ts +2 -2
- package/src/modules/create-one/create-one.module.d.ts +2 -2
- package/src/modules/delete-many/delete-many.helper.d.ts +2 -2
- package/src/modules/delete-many/delete-many.module.d.ts +2 -2
- package/src/modules/delete-one/delete-one.helper.d.ts +2 -2
- package/src/modules/delete-one/delete-one.module.d.ts +2 -2
- package/src/modules/duplicate-many/duplicate-many.helper.d.ts +2 -2
- package/src/modules/duplicate-many/duplicate-many.module.d.ts +2 -2
- package/src/modules/duplicate-one/duplicate-one.helper.d.ts +2 -2
- package/src/modules/duplicate-one/duplicate-one.module.d.ts +2 -2
- package/src/modules/get-many/get-many.helper.d.ts +2 -2
- package/src/modules/get-many/get-many.module.d.ts +2 -2
- package/src/modules/get-one/get-one.helper.d.ts +2 -2
- package/src/modules/get-one/get-one.module.d.ts +2 -2
- package/src/modules/replace-one/replace-one.helper.d.ts +2 -2
- package/src/modules/replace-one/replace-one.module.d.ts +2 -2
- package/src/modules/update-many/update-many.helper.d.ts +2 -2
- package/src/modules/update-many/update-many.module.d.ts +2 -2
- package/src/modules/update-one/update-one.helper.d.ts +2 -2
- package/src/modules/update-one/update-one.module.d.ts +2 -2
- package/src/version.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- /package/src/interfaces/{entity-mappers.interface.js → controller-options.interface.js} +0 -0
- /package/src/interfaces/{route-config.interface.js → dynamic-api-cache-options.interface.js} +0 -0
- /package/src/interfaces/{entity-mappers.interface.d.ts → dynamic-api-entity-mappers.interface.d.ts} +0 -0
- /package/src/interfaces/{service-provider.interface.js → dynamic-api-entity-mappers.interface.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
|
|
3
|
+
## [1.3.2](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v1.3.1...v1.3.2) (2024-03-05)
|
|
4
|
+
|
|
5
|
+
## [1.3.1](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v1.3.0...v1.3.1) (2024-03-05)
|
|
6
|
+
|
|
3
7
|
## [1.3.0](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v1.2.1...v1.3.0) (2024-03-04)
|
|
4
8
|
|
|
5
9
|
|
package/README.md
CHANGED
|
@@ -103,7 +103,9 @@ export class AppModule {}
|
|
|
103
103
|
**Basic Usage**
|
|
104
104
|
|
|
105
105
|
- Ok, now let's add our first content with just 2 files. It will be a simple `User` with a `name` and an `email` field.
|
|
106
|
-
- We use the `@Schema` and `@Prop` decorators from the `@nestjs/mongoose` package to define our MongoDB model.
|
|
106
|
+
- We use the `@Schema` and `@Prop` decorators from the `@nestjs/mongoose` package to define our MongoDB model. <br>*See <strong>nestjs</strong> <a href="https://docs.nestjs.com/techniques/mongodb#model-injection" target="_blank">documentation</a> for more details.*
|
|
107
|
+
|
|
108
|
+
|
|
107
109
|
- You must extend the `BaseEntity` (or `SoftDeletableEntity`) class from the `mongodb-dynamic-api` package **for all your collection models**.
|
|
108
110
|
- Just create a new file `user.ts` and add the following code.
|
|
109
111
|
|
|
@@ -114,10 +116,10 @@ import { BaseEntity } from 'mongodb-dynamic-api';
|
|
|
114
116
|
|
|
115
117
|
@Schema({ collection: 'users' })
|
|
116
118
|
export class User extends BaseEntity {
|
|
117
|
-
@Prop({ type: String })
|
|
119
|
+
@Prop({ type: String, required: true })
|
|
118
120
|
name: string;
|
|
119
121
|
|
|
120
|
-
@Prop({ type: String })
|
|
122
|
+
@Prop({ type: String, required: true })
|
|
121
123
|
email: string;
|
|
122
124
|
}
|
|
123
125
|
```
|
|
@@ -165,7 +167,23 @@ export class AppModule {}
|
|
|
165
167
|
|
|
166
168
|
**And that's all !** *You now have a fully functional CRUD API for the `User` content at the `/users` path.*
|
|
167
169
|
|
|
168
|
-
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
| Endpoint | Body | Param | Query |
|
|
173
|
+
|:--------------------------------------------------|:----------------------------------------------:|:------------:|:---------------:|
|
|
174
|
+
| **GET /users** <br>*Get many* | x | x | x |
|
|
175
|
+
| **GET /users/:id** <br>*Get one* | x | `id: string` | x |
|
|
176
|
+
| **POST /users/many** <br>*Create many* | `{ list: [{ name: string; email: string; }] }` | x | x |
|
|
177
|
+
| **POST /users** <br>*Create one* | `{ name: string; email: string; }` | x | x |
|
|
178
|
+
| **PUT /users/:id** <br>*Replace one* | `{ name: string; email: string; }` | `id: string` | x |
|
|
179
|
+
| **PATCH /users** <br>*Update many* | `{ name?: string; email?: string; }` | x | `ids: string[]` |
|
|
180
|
+
| **PATCH /users/:id** <br>*Update one* | `{ name?: string; email?: string; }` | `id: string` | x |
|
|
181
|
+
| **DELETE /users** <br>*Delete many* | x | x | `ids: string[]` |
|
|
182
|
+
| **DELETE /users/:id** <br>*Delete one* | x | `id: string` | x |
|
|
183
|
+
| **POST /users/duplicate** <br>*Duplicate many* | `{ name?: string; email?: string; }` | x | `ids: string[]` |
|
|
184
|
+
| **POST /users/duplicate/:id**<br>*Duplicate one* | `{ name?: string; email?: string; }` | `id: string` | x |
|
|
185
|
+
|
|
186
|
+
|
|
169
187
|
### [Swagger UI](https://docs.nestjs.com/openapi/introduction#document-options) (optional but strongly recommended)
|
|
170
188
|
`function enableDynamicAPISwagger(app: INestApplication, options?: DynamicAPISwaggerOptions): void`
|
|
171
189
|
|
|
@@ -200,15 +218,15 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
|
200
218
|
@Schema({ collection: 'users' })
|
|
201
219
|
export class User extends BaseEntity {
|
|
202
220
|
@ApiProperty() // <- add this line
|
|
203
|
-
@Prop({ type: String })
|
|
221
|
+
@Prop({ type: String, required: true })
|
|
204
222
|
name: string;
|
|
205
223
|
|
|
206
224
|
@ApiProperty() // <- add this line
|
|
207
|
-
@Prop({ type: String })
|
|
225
|
+
@Prop({ type: String, required: true })
|
|
208
226
|
email: string;
|
|
209
227
|
|
|
210
228
|
@ApiPropertyOptional() // <- add this line
|
|
211
|
-
@Prop({ type: String
|
|
229
|
+
@Prop({ type: String })
|
|
212
230
|
company?: string;
|
|
213
231
|
}
|
|
214
232
|
```
|
|
@@ -241,8 +259,7 @@ The `enableDynamicAPIValidation` function allow to configure the pipe validation
|
|
|
241
259
|
|
|
242
260
|
You can also define the pipe validation options in the `DynamicApiModule.forFeature` method, either in the controller options,
|
|
243
261
|
or in each route object defined in the routes property.
|
|
244
|
-
|
|
245
|
-
*If the options are specified in 2, the options specified in the route will have priority.*
|
|
262
|
+
<br>*If the options are specified in 2, the options specified in the route will have priority.*
|
|
246
263
|
|
|
247
264
|
```typescript
|
|
248
265
|
// users.module.ts
|
|
@@ -285,16 +302,16 @@ import { IsEmail } from 'class-validator';
|
|
|
285
302
|
@Schema({ collection: 'users' })
|
|
286
303
|
export class User extends BaseEntity {
|
|
287
304
|
@ApiProperty()
|
|
288
|
-
@Prop({ type: String })
|
|
305
|
+
@Prop({ type: String, required: true })
|
|
289
306
|
name: string;
|
|
290
307
|
|
|
291
308
|
@ApiProperty()
|
|
292
309
|
@IsEmail()
|
|
293
|
-
@Prop({ type: String })
|
|
310
|
+
@Prop({ type: String, required: true })
|
|
294
311
|
email: string;
|
|
295
312
|
|
|
296
313
|
@ApiPropertyOptional()
|
|
297
|
-
@Prop({ type: String
|
|
314
|
+
@Prop({ type: String })
|
|
298
315
|
company?: string;
|
|
299
316
|
}
|
|
300
317
|
```
|
|
@@ -308,6 +325,11 @@ ___
|
|
|
308
325
|
### [Versioning](https://docs.nestjs.com/techniques/versioning) (optional)
|
|
309
326
|
`function enableDynamicAPIVersioning(app: INestApplication, options?: VersioningOptions): void`
|
|
310
327
|
|
|
328
|
+
The `enableDynamicAPIVersioning` function will automatically add versioning to the API.
|
|
329
|
+
<br>By default, it will use the <strong>URI versioning type</strong>.
|
|
330
|
+
<br>This method can be called with a second <strong>optional parameter</strong> to specify custom options.
|
|
331
|
+
<br>*See <strong>nestjs</strong> <a href="https://docs.nestjs.com/techniques/versioning" target="_blank">documentation</a> for more details.*
|
|
332
|
+
|
|
311
333
|
**Configuration**
|
|
312
334
|
|
|
313
335
|
```typescript
|
|
@@ -323,11 +345,6 @@ async function bootstrap() {
|
|
|
323
345
|
}
|
|
324
346
|
```
|
|
325
347
|
|
|
326
|
-
The `enableDynamicAPIVersioning` function will automatically add versioning to the API.
|
|
327
|
-
<br>By default, it will use the <strong>URI versioning type</strong>.
|
|
328
|
-
<br>This method can be called with a second <strong>optional parameter</strong> to specify custom options.
|
|
329
|
-
<br>*See <strong>nestjs</strong> <a href="https://docs.nestjs.com/techniques/versioning" target="_blank">documentation</a> for more details.*
|
|
330
|
-
|
|
331
348
|
**Usage**
|
|
332
349
|
|
|
333
350
|
Pass the `version` property to the `controllerOptions` object or to the `route` object in the `DynamicApiModule.forFeature` method.
|
|
@@ -414,5 +431,84 @@ Great, now you have a versioned User API, and you can access it at the `/v1/user
|
|
|
414
431
|
|
|
415
432
|
___
|
|
416
433
|
|
|
417
|
-
|
|
434
|
+
### [Caching](https://docs.nestjs.com/techniques/caching#in-memory-cache) (enabled by default)
|
|
435
|
+
|
|
436
|
+
By default, the caching is activated globally for all the routes. It uses the nestjs built-in in-memory data store with the default options.
|
|
437
|
+
<br>You can configure the cache options by passing the `cacheOptions` in the second parameter of the `DynamicApiModule.forRoot` method.
|
|
438
|
+
|
|
439
|
+
**Configuration**
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
// app.module.ts
|
|
443
|
+
import { DynamicApiModule } from 'mongodb-dynamic-api';
|
|
444
|
+
|
|
445
|
+
@Module({
|
|
446
|
+
imports: [
|
|
447
|
+
DynamicApiModule.forRoot('...', {
|
|
448
|
+
cacheOptions: {
|
|
449
|
+
ttl: 60, // <- The time to live in milliseconds. This is the maximum amount of time that an item can be in the cache before it is removed.
|
|
450
|
+
max: 100, // <- The maximum number of items that can be stored in the cache.
|
|
451
|
+
},
|
|
452
|
+
}),
|
|
453
|
+
// ...
|
|
454
|
+
],
|
|
455
|
+
controllers: [AppController],
|
|
456
|
+
providers: [AppService],
|
|
457
|
+
})
|
|
458
|
+
export class AppModule {}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
*See <strong>nestjs</strong> <a href="https://docs.nestjs.com/techniques/caching" target="_blank">documentation</a> for more details.*
|
|
462
|
+
|
|
463
|
+
**[Not recommended]** The cache can also be disabled globally with the `useGlobalCache` property set to `false` in the `DynamicApiModule.forRoot` method.
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
// app.module.ts
|
|
467
|
+
import { DynamicApiModule } from 'mongodb-dynamic-api';
|
|
468
|
+
|
|
469
|
+
@Module({
|
|
470
|
+
imports: [
|
|
471
|
+
DynamicApiModule.forRoot('...', {
|
|
472
|
+
useGlobalCache: false, // <- add this line
|
|
473
|
+
}),
|
|
474
|
+
// ...
|
|
475
|
+
],
|
|
476
|
+
controllers: [AppController],
|
|
477
|
+
providers: [AppService],
|
|
478
|
+
})
|
|
479
|
+
export class AppModule {}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
**Usage**
|
|
483
|
+
|
|
484
|
+
When you request the `/users` route with the `GET` method, the response will be cached until the cache expires or until the maximum number of items is reached or until a request like `POST`, `PUT`, `PATCH`, or `DELETE` is made on the same route.
|
|
485
|
+
<br><br>Let's inspect the behavior in the network tab of our browser
|
|
486
|
+
<br>We expected to see a code `200` for the first GET request, a code `304`* for the second GET request, and again a code `200` for the third GET request made after the POST request.
|
|
487
|
+
|
|
488
|
+
**The 304 Not Modified redirect response code indicates that there is no need to retransmit the requested resources. This is an implicit redirection to a cached resource.*
|
|
489
|
+
|
|
490
|
+
```text
|
|
491
|
+
1. GET /users
|
|
492
|
+
```
|
|
493
|
+

|
|
494
|
+
|
|
495
|
+
```text
|
|
496
|
+
2. GET /users
|
|
497
|
+
```
|
|
498
|
+

|
|
499
|
+
```text
|
|
500
|
+
3. POST /users
|
|
501
|
+
```
|
|
502
|
+

|
|
503
|
+
```text
|
|
504
|
+
4. GET /users
|
|
505
|
+
```
|
|
506
|
+

|
|
507
|
+
|
|
508
|
+
___
|
|
509
|
+
|
|
510
|
+
More coming soon...
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
418
514
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb-dynamic-api",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Auto generated CRUD API for MongoDB using NestJS",
|
|
5
5
|
"readmeFilename": "README.md",
|
|
6
6
|
"main": "index.js",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://mikedev75015.github.io",
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@nestjs/cache-manager": "^2.2.1",
|
|
41
42
|
"@nestjs/common": "^10.3.2",
|
|
42
43
|
"@nestjs/core": "^10.3.2",
|
|
43
44
|
"@nestjs/mongoose": "^10.0.4",
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
"@nestjs/swagger": "^7.3.0",
|
|
46
47
|
"@types/lodash": "^4.14.202",
|
|
47
48
|
"builder-pattern": "^2.2.0",
|
|
49
|
+
"cache-manager": "^5.4.0",
|
|
48
50
|
"class-transformer": "^0.5.1",
|
|
49
51
|
"class-validator": "^0.14.1",
|
|
50
52
|
"lodash": "^4.17.21",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import {
|
|
2
|
+
import { DynamicApiForFeatureOptions, DynamicApiForRootOptions } from './interfaces';
|
|
3
3
|
import { BaseEntity } from './models';
|
|
4
4
|
export declare class DynamicApiModule {
|
|
5
5
|
static readonly connectionName = "dynamic-api-connection";
|
|
6
|
-
static
|
|
7
|
-
static
|
|
6
|
+
static isGlobalCacheEnabled: boolean;
|
|
7
|
+
static forRoot(uri: string, { useGlobalCache, cacheOptions }?: DynamicApiForRootOptions): DynamicModule;
|
|
8
|
+
static forFeature<Entity extends BaseEntity>({ entity, controllerOptions: { path, apiTag, version: controllerVersion, validationPipeOptions: controllerValidationPipeOptions, }, routes, }: DynamicApiForFeatureOptions<Entity>): DynamicModule;
|
|
8
9
|
}
|
|
@@ -8,7 +8,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var DynamicApiModule_1;
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.DynamicApiModule = void 0;
|
|
11
|
+
const cache_manager_1 = require("@nestjs/cache-manager");
|
|
11
12
|
const common_1 = require("@nestjs/common");
|
|
13
|
+
const core_1 = require("@nestjs/core");
|
|
12
14
|
const mongoose_1 = require("@nestjs/mongoose");
|
|
13
15
|
const decorators_1 = require("./decorators");
|
|
14
16
|
const helpers_1 = require("./helpers");
|
|
@@ -17,13 +19,17 @@ const delete_many_1 = require("./modules/delete-many");
|
|
|
17
19
|
const duplicate_many_1 = require("./modules/duplicate-many");
|
|
18
20
|
const update_many_1 = require("./modules/update-many");
|
|
19
21
|
let DynamicApiModule = DynamicApiModule_1 = class DynamicApiModule {
|
|
20
|
-
static forRoot(uri) {
|
|
22
|
+
static forRoot(uri, { useGlobalCache = true, cacheOptions = {} } = {}) {
|
|
21
23
|
if (!uri) {
|
|
22
24
|
throw new Error('You must provide a valid mongodb uri in the forRoot method to use MongoDB Dynamic API');
|
|
23
25
|
}
|
|
26
|
+
if (!useGlobalCache) {
|
|
27
|
+
DynamicApiModule_1.isGlobalCacheEnabled = false;
|
|
28
|
+
}
|
|
24
29
|
return {
|
|
25
30
|
module: DynamicApiModule_1,
|
|
26
31
|
imports: [
|
|
32
|
+
...(useGlobalCache ? [cache_manager_1.CacheModule.register({ isGlobal: true, ...cacheOptions })] : []),
|
|
27
33
|
mongoose_1.MongooseModule.forRoot(uri, { connectionName: DynamicApiModule_1.connectionName }),
|
|
28
34
|
],
|
|
29
35
|
};
|
|
@@ -111,11 +117,20 @@ let DynamicApiModule = DynamicApiModule_1 = class DynamicApiModule {
|
|
|
111
117
|
})
|
|
112
118
|
.filter((module) => module),
|
|
113
119
|
],
|
|
120
|
+
providers: [
|
|
121
|
+
...(DynamicApiModule_1.isGlobalCacheEnabled ? [
|
|
122
|
+
{
|
|
123
|
+
provide: core_1.APP_INTERCEPTOR,
|
|
124
|
+
useClass: cache_manager_1.CacheInterceptor,
|
|
125
|
+
},
|
|
126
|
+
] : []),
|
|
127
|
+
],
|
|
114
128
|
};
|
|
115
129
|
}
|
|
116
130
|
};
|
|
117
131
|
exports.DynamicApiModule = DynamicApiModule;
|
|
118
132
|
DynamicApiModule.connectionName = 'dynamic-api-connection';
|
|
133
|
+
DynamicApiModule.isGlobalCacheEnabled = true;
|
|
119
134
|
exports.DynamicApiModule = DynamicApiModule = DynamicApiModule_1 = __decorate([
|
|
120
135
|
(0, common_1.Module)({})
|
|
121
136
|
], DynamicApiModule);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CacheStore, CacheStoreFactory } from '@nestjs/cache-manager/dist/interfaces/cache-manager.interface';
|
|
2
|
+
interface DynamicApiCacheOptions {
|
|
3
|
+
max?: number;
|
|
4
|
+
ttl?: number;
|
|
5
|
+
store?: string | CacheStoreFactory | CacheStore;
|
|
6
|
+
isCacheableValue?: (value: any) => boolean;
|
|
7
|
+
}
|
|
8
|
+
export { DynamicApiCacheOptions };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Type
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
2
|
import { BaseEntity } from '../models';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { ControllerOptions } from './controller-options.interface';
|
|
4
|
+
import { DynamicApiCacheOptions } from './dynamic-api-cache-options.interface';
|
|
5
|
+
import { DynamicAPIRouteConfig } from './dynamic-api-route-config.interface';
|
|
6
|
+
interface DynamicApiForRootOptions {
|
|
7
|
+
useGlobalCache?: boolean;
|
|
8
|
+
cacheOptions?: DynamicApiCacheOptions;
|
|
9
9
|
}
|
|
10
|
-
interface
|
|
10
|
+
interface DynamicApiForFeatureOptions<Entity extends BaseEntity> {
|
|
11
11
|
entity: Type<Entity>;
|
|
12
12
|
controllerOptions: ControllerOptions;
|
|
13
|
-
routes?:
|
|
13
|
+
routes?: DynamicAPIRouteConfig<Entity>[];
|
|
14
14
|
}
|
|
15
|
-
export {
|
|
15
|
+
export { DynamicApiForFeatureOptions, DynamicApiForRootOptions };
|
package/src/interfaces/{route-config.interface.d.ts → dynamic-api-route-config.interface.d.ts}
RENAMED
|
@@ -7,11 +7,11 @@ type DTOsBundle = {
|
|
|
7
7
|
body?: Type;
|
|
8
8
|
presenter?: Type;
|
|
9
9
|
};
|
|
10
|
-
interface
|
|
10
|
+
interface DynamicAPIRouteConfig<Entity extends BaseEntity> {
|
|
11
11
|
type: RouteType;
|
|
12
12
|
description?: string;
|
|
13
13
|
version?: string;
|
|
14
14
|
dTOs?: DTOsBundle;
|
|
15
15
|
validationPipeOptions?: ValidationPipeOptions;
|
|
16
16
|
}
|
|
17
|
-
export { DTOsBundle, RouteType,
|
|
17
|
+
export { DTOsBundle, RouteType, DynamicAPIRouteConfig };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './controller-options.interface';
|
|
2
|
+
export * from './dynamic-api-entity-mappers.interface';
|
|
2
3
|
export * from './dynamic-api-options.interface';
|
|
3
4
|
export * from './dynamic-api-schema-options.interface';
|
|
4
5
|
export * from './dynamic-api-swagger-options.type';
|
|
5
|
-
export * from './route-config.interface';
|
|
6
|
-
export * from './service-provider.interface';
|
|
6
|
+
export * from './dynamic-api-route-config.interface';
|
|
7
|
+
export * from './dynamic-api-service-provider.interface';
|
package/src/interfaces/index.js
CHANGED
|
@@ -14,9 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./controller-options.interface"), exports);
|
|
18
|
+
__exportStar(require("./dynamic-api-entity-mappers.interface"), exports);
|
|
18
19
|
__exportStar(require("./dynamic-api-options.interface"), exports);
|
|
19
20
|
__exportStar(require("./dynamic-api-schema-options.interface"), exports);
|
|
20
21
|
__exportStar(require("./dynamic-api-swagger-options.type"), exports);
|
|
21
|
-
__exportStar(require("./route-config.interface"), exports);
|
|
22
|
-
__exportStar(require("./service-provider.interface"), exports);
|
|
22
|
+
__exportStar(require("./dynamic-api-route-config.interface"), exports);
|
|
23
|
+
__exportStar(require("./dynamic-api-service-provider.interface"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { DTOsBundle,
|
|
2
|
+
import { DTOsBundle, DynamicAPIServiceProvider } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
import { CreateManyControllerConstructor } from './create-many-controller.interface';
|
|
5
|
-
declare function createCreateManyServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined):
|
|
5
|
+
declare function createCreateManyServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined): DynamicAPIServiceProvider;
|
|
6
6
|
declare function createCreateManyController<Entity extends BaseEntity>(entity: Type<Entity>, path: string, apiTag?: string, version?: string, description?: string, DTOs?: DTOsBundle, validationPipeOptions?: ValidationPipeOptions): CreateManyControllerConstructor<Entity>;
|
|
7
7
|
export { createCreateManyController, createCreateManyServiceProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { ControllerOptions,
|
|
2
|
+
import { ControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
export declare class CreateManyModule {
|
|
5
|
-
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }:
|
|
5
|
+
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }: DynamicAPIRouteConfig<Entity>, version?: string, validationPipeOptions?: ValidationPipeOptions): DynamicModule;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { DTOsBundle,
|
|
2
|
+
import { DTOsBundle, DynamicAPIServiceProvider } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
import { CreateOneControllerConstructor } from './create-one-controller.interface';
|
|
5
|
-
declare function createCreateOneServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined):
|
|
5
|
+
declare function createCreateOneServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined): DynamicAPIServiceProvider;
|
|
6
6
|
declare function createCreateOneController<Entity extends BaseEntity>(entity: Type<Entity>, path: string, apiTag?: string, version?: string, description?: string, DTOs?: DTOsBundle, validationPipeOptions?: ValidationPipeOptions): CreateOneControllerConstructor<Entity>;
|
|
7
7
|
export { createCreateOneController, createCreateOneServiceProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { ControllerOptions,
|
|
2
|
+
import { ControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
export declare class CreateOneModule {
|
|
5
|
-
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }:
|
|
5
|
+
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }: DynamicAPIRouteConfig<Entity>, version?: string, validationPipeOptions?: ValidationPipeOptions): DynamicModule;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { DTOsBundle,
|
|
2
|
+
import { DTOsBundle, DynamicAPIServiceProvider } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
import { DeleteManyControllerConstructor } from './delete-many-controller.interface';
|
|
5
|
-
declare function createDeleteManyServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined):
|
|
5
|
+
declare function createDeleteManyServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined): DynamicAPIServiceProvider;
|
|
6
6
|
declare function createDeleteManyController<Entity extends BaseEntity>(entity: Type<Entity>, path: string, apiTag?: string, version?: string, description?: string, DTOs?: DTOsBundle, validationPipeOptions?: ValidationPipeOptions): DeleteManyControllerConstructor<Entity>;
|
|
7
7
|
export { createDeleteManyController, createDeleteManyServiceProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { ControllerOptions,
|
|
2
|
+
import { ControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
export declare class DeleteManyModule {
|
|
5
|
-
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }:
|
|
5
|
+
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }: DynamicAPIRouteConfig<Entity>, version?: string, validationPipeOptions?: ValidationPipeOptions): DynamicModule;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { DTOsBundle,
|
|
2
|
+
import { DTOsBundle, DynamicAPIServiceProvider } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
import { DeleteOneControllerConstructor } from './delete-one-controller.interface';
|
|
5
|
-
declare function createDeleteOneServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined):
|
|
5
|
+
declare function createDeleteOneServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined): DynamicAPIServiceProvider;
|
|
6
6
|
declare function createDeleteOneController<Entity extends BaseEntity>(entity: Type<Entity>, path: string, apiTag?: string, version?: string, description?: string, DTOs?: DTOsBundle, validationPipeOptions?: ValidationPipeOptions): DeleteOneControllerConstructor<Entity>;
|
|
7
7
|
export { createDeleteOneController, createDeleteOneServiceProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { ControllerOptions,
|
|
2
|
+
import { ControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
export declare class DeleteOneModule {
|
|
5
|
-
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }:
|
|
5
|
+
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }: DynamicAPIRouteConfig<Entity>, version?: string, validationPipeOptions?: ValidationPipeOptions): DynamicModule;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { DTOsBundle,
|
|
2
|
+
import { DTOsBundle, DynamicAPIServiceProvider } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
import { DuplicateManyControllerConstructor } from './duplicate-many-controller.interface';
|
|
5
|
-
declare function createDuplicateManyServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined):
|
|
5
|
+
declare function createDuplicateManyServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined): DynamicAPIServiceProvider;
|
|
6
6
|
declare function createDuplicateManyController<Entity extends BaseEntity>(entity: Type<Entity>, path: string, apiTag?: string, version?: string, description?: string, DTOs?: DTOsBundle, validationPipeOptions?: ValidationPipeOptions): DuplicateManyControllerConstructor<Entity>;
|
|
7
7
|
export { createDuplicateManyController, createDuplicateManyServiceProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { ControllerOptions,
|
|
2
|
+
import { ControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
export declare class DuplicateManyModule {
|
|
5
|
-
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }:
|
|
5
|
+
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }: DynamicAPIRouteConfig<Entity>, version?: string, validationPipeOptions?: ValidationPipeOptions): DynamicModule;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { DTOsBundle,
|
|
2
|
+
import { DTOsBundle, DynamicAPIServiceProvider } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
import { DuplicateOneControllerConstructor } from './duplicate-one-controller.interface';
|
|
5
|
-
declare function createDuplicateOneServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined):
|
|
5
|
+
declare function createDuplicateOneServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined): DynamicAPIServiceProvider;
|
|
6
6
|
declare function createDuplicateOneController<Entity extends BaseEntity>(entity: Type<Entity>, path: string, apiTag?: string, version?: string, description?: string, DTOs?: DTOsBundle, validationPipeOptions?: ValidationPipeOptions): DuplicateOneControllerConstructor<Entity>;
|
|
7
7
|
export { createDuplicateOneController, createDuplicateOneServiceProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { ControllerOptions,
|
|
2
|
+
import { ControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
export declare class DuplicateOneModule {
|
|
5
|
-
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }:
|
|
5
|
+
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }: DynamicAPIRouteConfig<Entity>, version?: string, validationPipeOptions?: ValidationPipeOptions): DynamicModule;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { DTOsBundle,
|
|
2
|
+
import { DTOsBundle, DynamicAPIServiceProvider } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
import { GetManyControllerConstructor } from './get-many-controller.interface';
|
|
5
|
-
declare function createGetManyServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined):
|
|
5
|
+
declare function createGetManyServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined): DynamicAPIServiceProvider;
|
|
6
6
|
declare function createGetManyController<Entity extends BaseEntity>(entity: Type<Entity>, path: string, apiTag?: string, version?: string, description?: string, DTOs?: DTOsBundle, validationPipeOptions?: ValidationPipeOptions): GetManyControllerConstructor<Entity>;
|
|
7
7
|
export { createGetManyController, createGetManyServiceProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { ControllerOptions,
|
|
2
|
+
import { ControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
export declare class GetManyModule {
|
|
5
|
-
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }:
|
|
5
|
+
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }: DynamicAPIRouteConfig<Entity>, version?: string, validationPipeOptions?: ValidationPipeOptions): DynamicModule;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { DTOsBundle,
|
|
2
|
+
import { DTOsBundle, DynamicAPIServiceProvider } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
import { GetOneControllerConstructor } from './get-one-controller.interface';
|
|
5
|
-
declare function createGetOneServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined):
|
|
5
|
+
declare function createGetOneServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined): DynamicAPIServiceProvider;
|
|
6
6
|
declare function createGetOneController<Entity extends BaseEntity>(entity: Type<Entity>, path: string, apiTag?: string, version?: string, description?: string, DTOs?: DTOsBundle, validationPipeOptions?: ValidationPipeOptions): GetOneControllerConstructor<Entity>;
|
|
7
7
|
export { createGetOneController, createGetOneServiceProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { ControllerOptions,
|
|
2
|
+
import { ControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
export declare class GetOneModule {
|
|
5
|
-
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }:
|
|
5
|
+
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }: DynamicAPIRouteConfig<Entity>, version?: string, validationPipeOptions?: ValidationPipeOptions): DynamicModule;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { DTOsBundle,
|
|
2
|
+
import { DTOsBundle, DynamicAPIServiceProvider } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
import { ReplaceOneControllerConstructor } from './replace-one-controller.interface';
|
|
5
|
-
declare function createReplaceOneServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined):
|
|
5
|
+
declare function createReplaceOneServiceProvider<Entity extends BaseEntity>(entity: Type<Entity>, version: string | undefined): DynamicAPIServiceProvider;
|
|
6
6
|
declare function createReplaceOneController<Entity extends BaseEntity>(entity: Type<Entity>, path: string, apiTag?: string, version?: string, description?: string, DTOs?: DTOsBundle, validationPipeOptions?: ValidationPipeOptions): ReplaceOneControllerConstructor<Entity>;
|
|
7
7
|
export { createReplaceOneController, createReplaceOneServiceProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Type, ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
-
import { ControllerOptions,
|
|
2
|
+
import { ControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
4
|
export declare class ReplaceOneModule {
|
|
5
|
-
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }:
|
|
5
|
+
static forFeature<Entity extends BaseEntity>(databaseModule: DynamicModule, entity: Type<Entity>, { path, apiTag }: ControllerOptions, { description, dTOs: DTOs }: DynamicAPIRouteConfig<Entity>, version?: string, validationPipeOptions?: ValidationPipeOptions): DynamicModule;
|
|
6
6
|
}
|