@nest-omni/core 1.0.56-2 → 1.0.56-4
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.
|
@@ -34,49 +34,37 @@ skip_if: <%= !blocks.includes('Controller') %>
|
|
|
34
34
|
GetDtoName = 'Get' + DtoName;
|
|
35
35
|
getDtoFileName = 'get-' + dtoFileName;
|
|
36
36
|
|
|
37
|
-
%>import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
37
|
+
%>import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
|
38
|
+
import { <%= classify(name) %>Service } from './<%= name %>.service';
|
|
39
|
+
import { Create<%= classify(name) %>Dto } from './dto/create-<%= name %>.dto';
|
|
40
|
+
import { Update<%= classify(name) %>Dto } from './dto/update-<%= name %>.dto';
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
@Controller('<%= name %>')
|
|
43
|
+
export class <%= classify(name) %>Controller {
|
|
44
|
+
constructor(private readonly <%= camelize(name) %>Service: <%= classify(name) %>Service) {}
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
import { BulkIdDto } from '@nest-omni/core/common/dto/bulk-id.dto';
|
|
46
|
+
@Post()
|
|
47
|
+
create(@Body() create<%= classify(name) %>Dto: Create<%= classify(name) %>Dto) {
|
|
48
|
+
return this.<%= camelize(name) %>Service.create(create<%= classify(name) %>Dto);
|
|
49
|
+
}
|
|
49
50
|
|
|
50
|
-
@
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
query: {
|
|
55
|
-
alwaysPaginate: true,
|
|
56
|
-
},
|
|
57
|
-
})
|
|
58
|
-
@Controller('<%= h.inflection.pluralize(fileName).toLowerCase() %>')
|
|
59
|
-
@ApiTags('<%= h.inflection.pluralize(fileName).toLowerCase() %>')
|
|
60
|
-
export class <%= ControllerName %> {
|
|
61
|
-
constructor(
|
|
62
|
-
public service: <%= ServiceName %>,
|
|
63
|
-
public i18n: I18nService,
|
|
64
|
-
) {}
|
|
51
|
+
@Get()
|
|
52
|
+
findAll() {
|
|
53
|
+
return this.<%= camelize(name) %>Service.findAll();
|
|
54
|
+
}
|
|
65
55
|
|
|
66
|
-
@
|
|
67
|
-
|
|
68
|
-
return
|
|
56
|
+
@Get(':id')
|
|
57
|
+
findOne(@Param('id') id: string) {
|
|
58
|
+
return this.<%= camelize(name) %>Service.findOne(id);
|
|
69
59
|
}
|
|
70
60
|
|
|
71
|
-
@
|
|
72
|
-
|
|
73
|
-
return
|
|
61
|
+
@Patch(':id')
|
|
62
|
+
update(@Param('id') id: string, @Body() update<%= classify(name) %>Dto: Update<%= classify(name) %>Dto) {
|
|
63
|
+
return this.<%= camelize(name) %>Service.update(id, update<%= classify(name) %>Dto);
|
|
74
64
|
}
|
|
75
65
|
|
|
76
|
-
@Delete('
|
|
77
|
-
@
|
|
78
|
-
|
|
79
|
-
async deleteBulk(@Body() bulkId: BulkIdDto) {
|
|
80
|
-
return await this.service.deleteBulk(bulkId);
|
|
66
|
+
@Delete(':id')
|
|
67
|
+
remove(@Param('id') id: string) {
|
|
68
|
+
return this.<%= camelize(name) %>Service.remove(id);
|
|
81
69
|
}
|
|
82
70
|
}
|
package/package.json
CHANGED
package/setup/bootstrap.setup.js
CHANGED
|
@@ -24,6 +24,7 @@ const nestjs_i18n_1 = require("nestjs-i18n");
|
|
|
24
24
|
const crud_1 = require("@dataui/crud");
|
|
25
25
|
const nestjs_cls_1 = require("nestjs-cls");
|
|
26
26
|
const compression = require("compression");
|
|
27
|
+
const class_validator_1 = require("class-validator");
|
|
27
28
|
crud_1.CrudConfigService.load({
|
|
28
29
|
auth: {
|
|
29
30
|
property: 'user',
|
|
@@ -118,6 +119,7 @@ function bootstrapSetup(AppModule, SetupSwagger) {
|
|
|
118
119
|
const app = yield core_1.NestFactory.create(AppModule, {
|
|
119
120
|
bufferLogs: true,
|
|
120
121
|
});
|
|
122
|
+
(0, class_validator_1.useContainer)(app.select(AppModule), { fallbackOnErrors: true });
|
|
121
123
|
const configService = app.select(__1.ServiceRegistryModule).get(__1.ApiConfigService);
|
|
122
124
|
const logger = app.get(nestjs_pino_1.Logger);
|
|
123
125
|
setupProcessHandlers(app);
|
|
@@ -33,6 +33,7 @@ const health_checker_module_1 = require("../health-checker/health-checker.module
|
|
|
33
33
|
const services_1 = require("./services");
|
|
34
34
|
const fs_1 = require("fs");
|
|
35
35
|
const path_1 = require("path");
|
|
36
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
36
37
|
const providers = [
|
|
37
38
|
services_1.ApiConfigService,
|
|
38
39
|
services_1.ValidatorService,
|
|
@@ -77,6 +78,10 @@ const modules = [
|
|
|
77
78
|
expandVariables: false,
|
|
78
79
|
envFilePath: [envFilePath, baseEnvFilePath],
|
|
79
80
|
}),
|
|
81
|
+
nestjs_cls_1.ClsModule.forRoot({
|
|
82
|
+
global: true,
|
|
83
|
+
middleware: { mount: true },
|
|
84
|
+
}),
|
|
80
85
|
nestjs_sentry_1.SentryModule.forRootAsync({
|
|
81
86
|
inject: [services_1.ApiConfigService],
|
|
82
87
|
useFactory(configService) {
|