@steroidsjs/nest 4.1.0 → 4.2.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/README.md +6 -12
- package/infrastructure/applications/BaseApplication.d.ts +7 -0
- package/infrastructure/applications/BaseApplication.js +37 -0
- package/infrastructure/applications/BaseApplication.js.map +1 -1
- package/infrastructure/applications/base/config.js +2 -5
- package/infrastructure/applications/base/config.js.map +1 -1
- package/infrastructure/applications/rest/IRestAppModuleConfig.d.ts +5 -0
- package/infrastructure/applications/rest/RestApplication.d.ts +4 -11
- package/infrastructure/applications/rest/RestApplication.js +13 -16
- package/infrastructure/applications/rest/RestApplication.js.map +1 -1
- package/infrastructure/applications/rest/SentryExceptionFilter.js +1 -1
- package/infrastructure/applications/rest/SentryExceptionFilter.js.map +1 -1
- package/infrastructure/applications/rest/config.d.ts +3 -20
- package/infrastructure/applications/rest/config.js +1 -1
- package/infrastructure/applications/rest/config.js.map +1 -1
- package/infrastructure/commands/entity-generator/EntityCodeGenerateCommand.d.ts +1 -1
- package/infrastructure/commands/entity-generator/EntityCodeGenerateCommand.js +9 -4
- package/infrastructure/commands/entity-generator/EntityCodeGenerateCommand.js.map +1 -1
- package/infrastructure/commands/entity-generator/EntityCodeGenerator.d.ts +3 -1
- package/infrastructure/commands/entity-generator/EntityCodeGenerator.js +24 -6
- package/infrastructure/commands/entity-generator/EntityCodeGenerator.js.map +1 -1
- package/infrastructure/commands/entity-generator/templates/{ServiceTemplate.txt → CrudServiceTemplate.txt} +4 -1
- package/infrastructure/commands/entity-generator/templates/ReadServiceTemplate.txt +18 -0
- package/infrastructure/commands/entity-generator/templates/TableTemplate.txt +1 -1
- package/infrastructure/decorators/fields/EnumField.d.ts +3 -2
- package/infrastructure/decorators/fields/EnumField.js +2 -1
- package/infrastructure/decorators/fields/EnumField.js.map +1 -1
- package/infrastructure/decorators/fields/PasswordField.d.ts +9 -1
- package/infrastructure/decorators/fields/PasswordField.js +12 -4
- package/infrastructure/decorators/fields/PasswordField.js.map +1 -1
- package/infrastructure/decorators/fields/index.d.ts +2 -2
- package/infrastructure/decorators/fields/index.js.map +1 -1
- package/infrastructure/decorators/typeorm/fields/TypeOrmUpdateTimeField/TypeOrmUpdateTimeBehaviour.js +1 -1
- package/infrastructure/repositories/CrudRepository.d.ts +2 -2
- package/infrastructure/repositories/CrudRepository.js +4 -6
- package/infrastructure/repositories/CrudRepository.js.map +1 -1
- package/package.json +2 -4
- package/tsconfig.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Steroids Nest
|
|
2
2
|
|
|
3
|
+
Steroids Nest — это библиотека инструментов и утилит для фреймворка NestJS, предоставляющая расширенные возможности
|
|
4
|
+
для разработки веб-приложений.
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
2. Replace `outDir` path to node_modules nest path in project
|
|
8
|
-
3. Run from this directory `yarn run watch`
|
|
9
|
-
|
|
10
|
-
## All scripts available
|
|
11
|
-
```
|
|
12
|
-
yarn script
|
|
13
|
-
```
|
|
14
|
-
|
|
6
|
+
Документация по библиотеке доступна:
|
|
7
|
+
- в папке [`docs` в этом репозитории](docs/README.md)
|
|
8
|
+
- на сайте [https://steroids.github.io/nest](https://steroids.github.io/nest)
|
|
@@ -27,6 +27,13 @@ export declare abstract class BaseApplication {
|
|
|
27
27
|
* @protected
|
|
28
28
|
*/
|
|
29
29
|
protected initConfig(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Initializes Sentry for error tracking and logging.
|
|
32
|
+
*
|
|
33
|
+
* Sentry also automatically configures `process.on('uncaughtException')` and `process.on('unhandledRejection')` to log and handle these events,
|
|
34
|
+
* only on `uncaughtException` the process will be exited, but on `unhandledRejection` it will continue to work.
|
|
35
|
+
*/
|
|
36
|
+
protected initSentry(): void;
|
|
30
37
|
/**
|
|
31
38
|
* Method for initializing application modules.
|
|
32
39
|
* It uses the `ModuleHelper` class.
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseApplication = void 0;
|
|
4
4
|
const dotenv = require("dotenv");
|
|
5
|
+
const Sentry = require("@sentry/nestjs");
|
|
5
6
|
const ModuleHelper_1 = require("../helpers/ModuleHelper");
|
|
7
|
+
const AppModule_1 = require("./AppModule");
|
|
6
8
|
/**
|
|
7
9
|
* Abstract class for creating application configuration classes.
|
|
8
10
|
*/
|
|
@@ -15,6 +17,7 @@ class BaseApplication {
|
|
|
15
17
|
async init() {
|
|
16
18
|
this.initEnv();
|
|
17
19
|
this.initConfig();
|
|
20
|
+
this.initSentry();
|
|
18
21
|
this.initModules();
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
@@ -37,6 +40,40 @@ class BaseApplication {
|
|
|
37
40
|
*/
|
|
38
41
|
initConfig() {
|
|
39
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Initializes Sentry for error tracking and logging.
|
|
45
|
+
*
|
|
46
|
+
* Sentry also automatically configures `process.on('uncaughtException')` and `process.on('unhandledRejection')` to log and handle these events,
|
|
47
|
+
* only on `uncaughtException` the process will be exited, but on `unhandledRejection` it will continue to work.
|
|
48
|
+
*/
|
|
49
|
+
initSentry() {
|
|
50
|
+
const config = ModuleHelper_1.ModuleHelper.getConfig(AppModule_1.AppModule);
|
|
51
|
+
if (!config.sentry) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
Sentry.init({
|
|
55
|
+
dsn: config.sentry.dsn,
|
|
56
|
+
environment: config.sentry.environment,
|
|
57
|
+
integrations: [
|
|
58
|
+
Sentry.onUncaughtExceptionIntegration({
|
|
59
|
+
onFatalError: async (err) => {
|
|
60
|
+
if (err.name === 'SentryError') {
|
|
61
|
+
console.log(err);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
Sentry.getCurrentScope()
|
|
65
|
+
.getClient()
|
|
66
|
+
.captureException(err);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
Sentry.onUnhandledRejectionIntegration({
|
|
72
|
+
mode: 'warn',
|
|
73
|
+
}),
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
}
|
|
40
77
|
/**
|
|
41
78
|
* Method for initializing application modules.
|
|
42
79
|
* It uses the `ModuleHelper` class.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseApplication.js","sourceRoot":"","sources":["../../../src/infrastructure/applications/BaseApplication.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,0DAAqD;
|
|
1
|
+
{"version":3,"file":"BaseApplication.js","sourceRoot":"","sources":["../../../src/infrastructure/applications/BaseApplication.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,yCAAyC;AACzC,0DAAqD;AACrD,2CAAsC;AAGtC;;GAEG;AACH,MAAsB,eAAe;IAOjC;;;;OAIG;IACO,KAAK,CAAC,IAAI;QAChB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACO,OAAO;QACb,MAAM,CAAC,MAAM,EAAE,CAAC;QAEhB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;SAC/D;IACL,CAAC;IAED;;;;OAIG;IACO,UAAU;IAEpB,CAAC;IAED;;;;;OAKG;IACO,UAAU;QAChB,MAAM,MAAM,GAAG,2BAAY,CAAC,SAAS,CAAmB,qBAAS,CAAC,CAAC;QAEnE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAChB,OAAO;SACV;QAED,MAAM,CAAC,IAAI,CAAC;YACR,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;YACtB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW;YACtC,YAAY,EAAE;gBACV,MAAM,CAAC,8BAA8B,CAAC;oBAClC,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;wBACxB,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,EAAE;4BAC5B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;yBACpB;6BAAM;4BACH,MAAM,CAAC,eAAe,EAAE;iCACnB,SAAS,EAAE;iCACX,gBAAgB,CAAC,GAAG,CAAC,CAAC;4BAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;yBACnB;oBACL,CAAC;iBACJ,CAAC;gBACF,MAAM,CAAC,+BAA+B,CAAC;oBACnC,IAAI,EAAE,MAAM;iBACf,CAAC;aACL;SACJ,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACO,WAAW;QACjB,2BAAY,CAAC,eAAe,EAAE,CAAC;IACnC,CAAC;CAMJ;AA5FD,0CA4FC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const nest_typeorm_1 = require("@steroidsjs/nest-typeorm");
|
|
4
|
-
const
|
|
4
|
+
const setup_1 = require("@sentry/nestjs/setup");
|
|
5
5
|
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
6
6
|
const ModuleHelper_1 = require("../../helpers/ModuleHelper");
|
|
7
7
|
const AppModule_1 = require("../AppModule");
|
|
@@ -28,10 +28,7 @@ exports.default = {
|
|
|
28
28
|
module: (config) => ({
|
|
29
29
|
imports: [
|
|
30
30
|
nest_typeorm_1.TypeOrmModule.forRoot(Object.assign(Object.assign({}, config.database), { entities: ModuleHelper_1.ModuleHelper.getEntities() })),
|
|
31
|
-
config.sentry &&
|
|
32
|
-
dsn: config.sentry.dsn,
|
|
33
|
-
environment: config.sentry.environment || process.env.APP_ENVIRONMENT,
|
|
34
|
-
}),
|
|
31
|
+
config.sentry && setup_1.SentryModule.forRoot(),
|
|
35
32
|
event_emitter_1.EventEmitterModule.forRoot(),
|
|
36
33
|
].filter(Boolean),
|
|
37
34
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/base/config.ts"],"names":[],"mappings":";;AAAA,2DAA6E;AAE7E,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/base/config.ts"],"names":[],"mappings":";;AAAA,2DAA6E;AAE7E,gDAAkD;AAClD,yDAAyD;AACzD,6DAAwD;AACxD,4CAAuC;AAEvC,8EAAyE;AAEzE,kBAAe;IACX,UAAU,EAAE,qBAAS;IACrB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACX,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,aAAa;QACpB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE;YACN,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;YACnC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC;YACjD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;YACvC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC3C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC3C,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE,KAAK;YACpB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAA,eAAe,CAAC;YAChE,cAAc,EAAE,IAAI,+CAAsB,EAAE;SAClB;KACZ,CAAA;IACtB,MAAM,EAAE,CAAC,MAAwB,EAAE,EAAE,CAAC,CAAC;QACnC,OAAO,EAAE;YACL,4BAAa,CAAC,OAAO,CAAC,gCACf,MAAM,CAAC,QAAQ,KAClB,QAAQ,EAAE,2BAAY,CAAC,WAAW,EAAE,GACf,CAAC;YAC1B,MAAM,CAAC,MAAM,IAAI,oBAAY,CAAC,OAAO,EAAE;YACvC,kCAAkB,CAAC,OAAO,EAAE;SAC/B,CAAC,MAAM,CAAC,OAAO,CAAC;KACpB,CAAC;CACL,CAAC"}
|
|
@@ -23,4 +23,9 @@ export interface IRestAppModuleConfig extends IAppModuleConfig {
|
|
|
23
23
|
* Enables .enableShutdownHooks() for NestJS app
|
|
24
24
|
*/
|
|
25
25
|
gracefulEnabled?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Is listen on localhost only?
|
|
28
|
+
* (value from `process.env.APP_LISTEN_LOCALHOST`)
|
|
29
|
+
*/
|
|
30
|
+
isListenLocalhost?: boolean;
|
|
26
31
|
}
|
|
@@ -48,19 +48,12 @@ export declare class RestApplication extends BaseApplication {
|
|
|
48
48
|
protected initPipes(): void;
|
|
49
49
|
/**
|
|
50
50
|
* Initialize global exception filters
|
|
51
|
-
* (by default, `ValidationExceptionFilter` and `UserExceptionFilter` are used).
|
|
52
|
-
* @protected
|
|
53
|
-
*/
|
|
54
|
-
protected initFilters(): void;
|
|
55
|
-
/**
|
|
56
|
-
* Initializes Sentry for error tracking and logging.
|
|
57
|
-
* If the environment variable `APP_SENTRY_DSN` is set, the filter `SentryExceptionFilter` is added.
|
|
58
51
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
52
|
+
* (by default, `ValidationExceptionFilter` and `UserExceptionFilter` are used.
|
|
53
|
+
* If the environment variable `APP_SENTRY_DSN` is set, the filter `SentryExceptionFilter` is added).
|
|
61
54
|
* @protected
|
|
62
55
|
*/
|
|
63
|
-
protected
|
|
56
|
+
protected initFilters(): void;
|
|
64
57
|
/**
|
|
65
58
|
* Initialization of global interceptors (default is `SchemaSerializer`).
|
|
66
59
|
* @protected
|
|
@@ -84,7 +77,7 @@ export declare class RestApplication extends BaseApplication {
|
|
|
84
77
|
/**
|
|
85
78
|
* Starts the application. Calls the `init` method and then starts the server on the specified port.
|
|
86
79
|
*/
|
|
87
|
-
start(): Promise<
|
|
80
|
+
start(): Promise<any>;
|
|
88
81
|
/**
|
|
89
82
|
* Getter for `_app`
|
|
90
83
|
*/
|
|
@@ -106,27 +106,19 @@ class RestApplication extends BaseApplication_1.BaseApplication {
|
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Initialize global exception filters
|
|
109
|
-
*
|
|
109
|
+
*
|
|
110
|
+
* (by default, `ValidationExceptionFilter` and `UserExceptionFilter` are used.
|
|
111
|
+
* If the environment variable `APP_SENTRY_DSN` is set, the filter `SentryExceptionFilter` is added).
|
|
110
112
|
* @protected
|
|
111
113
|
*/
|
|
112
114
|
initFilters() {
|
|
115
|
+
if (this._config.sentry) {
|
|
116
|
+
this._app.useGlobalFilters(new SentryExceptionFilter_1.SentryExceptionFilter(this._config.sentry.exposeSentryErrorResponse));
|
|
117
|
+
}
|
|
113
118
|
// Validation
|
|
114
119
|
this._app.useGlobalFilters(new ValidationExceptionFilter_1.ValidationExceptionFilter());
|
|
115
120
|
this._app.useGlobalFilters(new UserExceptionFilter_1.UserExceptionFilter());
|
|
116
121
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Initializes Sentry for error tracking and logging.
|
|
119
|
-
* If the environment variable `APP_SENTRY_DSN` is set, the filter `SentryExceptionFilter` is added.
|
|
120
|
-
*
|
|
121
|
-
* Sentry also automatically configures `process.on('uncaughtException')` and `process.on('unhandledRejection')` to log and handle these events,
|
|
122
|
-
* only on `uncaughtException` the process will be exited, but on `unhandledRejection` it will continue to work.
|
|
123
|
-
* @protected
|
|
124
|
-
*/
|
|
125
|
-
initSentry() {
|
|
126
|
-
if (process.env.APP_SENTRY_DSN) {
|
|
127
|
-
this._app.useGlobalFilters(new SentryExceptionFilter_1.SentryExceptionFilter(this._config.sentry.exposeSentryErrorResponse));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
122
|
/**
|
|
131
123
|
* Initialization of global interceptors (default is `SchemaSerializer`).
|
|
132
124
|
* @protected
|
|
@@ -164,7 +156,6 @@ class RestApplication extends BaseApplication_1.BaseApplication {
|
|
|
164
156
|
this.initCors();
|
|
165
157
|
this.initPipes();
|
|
166
158
|
this.initFilters();
|
|
167
|
-
this.initSentry();
|
|
168
159
|
this.initInterceptors();
|
|
169
160
|
this.initSettings();
|
|
170
161
|
this.initGraceful();
|
|
@@ -176,7 +167,13 @@ class RestApplication extends BaseApplication_1.BaseApplication {
|
|
|
176
167
|
await this.init();
|
|
177
168
|
// Start application
|
|
178
169
|
const port = parseInt(process.env.PORT, 10);
|
|
179
|
-
|
|
170
|
+
// eslint-disable-line no-console
|
|
171
|
+
const onStartCallback = () => console.log(`Server started http://localhost:${port}`);
|
|
172
|
+
const appListenArguments = this._config.isListenLocalhost
|
|
173
|
+
? [port, 'localhost', onStartCallback]
|
|
174
|
+
: [port, onStartCallback];
|
|
175
|
+
// @ts-ignore
|
|
176
|
+
return this._app.listen(...appListenArguments);
|
|
180
177
|
}
|
|
181
178
|
/**
|
|
182
179
|
* Getter for `_app`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RestApplication.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/RestApplication.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AACpD,6CAA6C;AAC7C,6CAA+D;AAC/D,2CAAgE;AAChE,mEAA8D;AAC9D,yDAAoD;AAEpD,6DAAwD;AACxD,uFAAkF;AAClF,2EAAsE;AACtE,wDAAmD;AACnD,6DAAwD;AACxD,4CAAuC;AAEvC;;GAEG;AACH,MAAa,eAAgB,SAAQ,iCAAe;IAoBhD,YAAY,WAAW,GAAG,qBAAS;QAC/B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACO,UAAU;QAChB,MAAM,MAAM,GAAG,2BAAY,CAAC,SAAS,CAAuB,IA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O,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACpD,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACvB;iBAAM;gBACH,MAAM,CAAC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC;gBACjC,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;aACnC;QACL,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;YACjB,WAAW,EAAE,IAAI;YACjB,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY;YACvC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY;SACjD,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACO,SAAS;QACf,aAAa;QACb,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,6BAAa,EAAE,CAAC,CAAC;IAClD,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"RestApplication.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/RestApplication.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AACpD,6CAA6C;AAC7C,6CAA+D;AAC/D,2CAAgE;AAChE,mEAA8D;AAC9D,yDAAoD;AAEpD,6DAAwD;AACxD,uFAAkF;AAClF,2EAAsE;AACtE,wDAAmD;AACnD,6DAAwD;AACxD,4CAAuC;AAEvC;;GAEG;AACH,MAAa,eAAgB,SAAQ,iCAAe;IAoBhD,YAAY,WAAW,GAAG,qBAAS;QAC/B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACO,UAAU;QAChB,MAAM,MAAM,GAAG,2BAAY,CAAC,SAAS,CAAuB,IAAI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GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,IAAI,EAAE,CAAC,CAAC;QACrF,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB;YACrD,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,eAAe,CAAC;YACtC,CAAC,CAAC,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QAE9B,aAAa;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,kBAAkB,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACI,MAAM;QACT,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;CACJ;AArND,0CAqNC"}
|
|
@@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SentryExceptionFilter = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
|
-
const Sentry = require("@sentry/
|
|
14
|
+
const Sentry = require("@sentry/nestjs");
|
|
15
15
|
const uuid_1 = require("uuid");
|
|
16
16
|
let SentryExceptionFilter = class SentryExceptionFilter {
|
|
17
17
|
constructor(exposeErrorResponse) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentryExceptionFilter.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/SentryExceptionFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAgG;AAEhG,
|
|
1
|
+
{"version":3,"file":"SentryExceptionFilter.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/SentryExceptionFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAgG;AAEhG,yCAAyC;AACzC,+BAAkC;AAI3B,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,YAA6B,mBAA4B;QAA5B,wBAAmB,GAAnB,mBAAmB,CAAS;IAAG,CAAC;IAE7D,KAAK,C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Q,EAAE;YACV,SAAS,CAAC,OAAO,IAAI,YAAY,QAAQ,EAAE,CAAC;SAC/C;QAED,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;QAClC,QAAQ;aACH,MAAM,CAAC,mBAAU,CAAC,qBAAqB,CAAC;aACxC,IAAI,CAAC;YACF,UAAU,EAAE,mBAAU,CAAC,qBAAqB;YAC5C,OAAO;SACV,CAAC,CAAC;IACX,CAAC;CACJ,CAAA;AAzDY,qBAAqB;IADjC,IAAA,cAAK,EAAC,KAAK,CAAC;;GACA,qBAAqB,CAyDjC;AAzDY,sDAAqB"}
|
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
import { IRestAppModuleConfig } from './IRestAppModuleConfig';
|
|
2
2
|
import { RequestExecutionExceptionFilter } from './filters/RequestExecutionExceptionFilter';
|
|
3
|
-
import { GracefulController } from
|
|
4
|
-
import { GracefulService } from
|
|
3
|
+
import { GracefulController } from './graceful/GracefulController';
|
|
4
|
+
import { GracefulService } from './graceful/GracefulService';
|
|
5
5
|
import { ValidationExceptionFilter } from '../../filters/ValidationExceptionFilter';
|
|
6
6
|
declare const _default: {
|
|
7
|
-
config: () =>
|
|
8
|
-
sentry: {
|
|
9
|
-
dsn: string;
|
|
10
|
-
environment: string;
|
|
11
|
-
exposeSentryErrorResponse: boolean;
|
|
12
|
-
};
|
|
13
|
-
name: string;
|
|
14
|
-
title: string;
|
|
15
|
-
version: string;
|
|
16
|
-
database?: {
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
host: string;
|
|
19
|
-
port: number;
|
|
20
|
-
database: string;
|
|
21
|
-
username: string;
|
|
22
|
-
password: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
7
|
+
config: () => IRestAppModuleConfig;
|
|
25
8
|
module: (config: IRestAppModuleConfig) => {
|
|
26
9
|
providers: (typeof GracefulService | {
|
|
27
10
|
provide: string;
|
|
@@ -11,7 +11,7 @@ exports.default = Object.assign(Object.assign({}, config_1.default), { config: (
|
|
|
11
11
|
dsn: process.env.APP_SENTRY_DSN,
|
|
12
12
|
environment: process.env.APP_ENVIRONMENT,
|
|
13
13
|
exposeSentryErrorResponse: (0, BooleanField_1.normalizeBoolean)(process.env.APP_ENVIRONMENT === 'dev' || process.env.SENTRY_EXPOSE_ERROR_RESPONSE),
|
|
14
|
-
} })), module: (config) => (Object.assign(Object.assign({}, config_1.default.module(config)), { providers: [
|
|
14
|
+
}, isListenLocalhost: (0, BooleanField_1.normalizeBoolean)(process.env.APP_LISTEN_LOCALHOST) })), module: (config) => (Object.assign(Object.assign({}, config_1.default.module(config)), { providers: [
|
|
15
15
|
{
|
|
16
16
|
provide: core_1.APP_FILTER,
|
|
17
17
|
useClass: ValidationExceptionFilter_1.ValidationExceptionFilter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/config.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AACxC,2CAAwC;AAExC,+FAA0F;AAC1F,sEAAiE;AACjE,gEAA2D;AAC3D,uFAAkF;AAClF,uEAAsE;AAEtE,kDACO,gBAAU,KACb,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/config.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AACxC,2CAAwC;AAExC,+FAA0F;AAC1F,sEAAiE;AACjE,gEAA2D;AAC3D,uFAAkF;AAClF,uEAAsE;AAEtE,kDACO,gBAAU,KACb,MAAM,EAAE,GAAyB,EAAE,CAAC,iCAC7B,gBAAU,CAAC,MAAM,EAAE,KACtB,MAAM,EAAE;YACJ,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;YAC/B,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;YACxC,yBAAyB,EAAE,IAAA,+BAAgB,EAAC,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;SACjI,EACD,iBAAiB,EAAE,IAAA,+BAAgB,EAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,IACvE,EACF,MAAM,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,iCACnC,gBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,KAC5B,SAAS,EAAE;YACP;gBACI,OAAO,EAAE,iBAAU;gBACnB,QAAQ,EAAE,qDAAyB;aACtC;YACD;gBACI,OAAO,EAAE,iBAAU;gBACnB,QAAQ,EAAE,iEAA+B;aAC5C;YACD,MAAM,CAAC,eAAe,IAAI,iCAAe;SAC5C,CAAC,MAAM,CAAC,OAAO,CAAC,EACjB,WAAW,EAAE;YACT,MAAM,CAAC,eAAe,IAAI,uCAAkB;SAC/C,CAAC,MAAM,CAAC,OAAO,CAAC,IACnB,IACJ"}
|
|
@@ -21,16 +21,16 @@ let EntityCodeGenerateCommand = class EntityCodeGenerateCommand {
|
|
|
21
21
|
* Example:
|
|
22
22
|
* yarn cli entity:generate entity module
|
|
23
23
|
*/
|
|
24
|
-
async index(entityName, moduleName) {
|
|
24
|
+
async index(entityName, moduleName, onlyReadService) {
|
|
25
25
|
if (!entityName || !moduleName) {
|
|
26
26
|
throw new Error('Required parameters are not provided');
|
|
27
27
|
}
|
|
28
|
-
(new EntityCodeGenerator_1.EntityCodeGenerator(entityName, moduleName)).generate();
|
|
28
|
+
(new EntityCodeGenerator_1.EntityCodeGenerator(entityName, moduleName, null, onlyReadService)).generate();
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
__decorate([
|
|
32
32
|
(0, nestjs_command_1.Command)({
|
|
33
|
-
command: 'entity:generate <entityName> <moduleName>',
|
|
33
|
+
command: 'entity:generate <entityName> <moduleName> [onlyReadService]',
|
|
34
34
|
describe: 'Generate code for entity (model, repository, dtos and so on...)',
|
|
35
35
|
}),
|
|
36
36
|
__param(0, (0, nestjs_command_1.Positional)({
|
|
@@ -43,8 +43,13 @@ __decorate([
|
|
|
43
43
|
describe: 'A module to put the code in',
|
|
44
44
|
type: 'string',
|
|
45
45
|
})),
|
|
46
|
+
__param(2, (0, nestjs_command_1.Positional)({
|
|
47
|
+
name: 'onlyReadService',
|
|
48
|
+
describe: 'Generate only read service entities',
|
|
49
|
+
type: 'boolean',
|
|
50
|
+
})),
|
|
46
51
|
__metadata("design:type", Function),
|
|
47
|
-
__metadata("design:paramtypes", [String, String]),
|
|
52
|
+
__metadata("design:paramtypes", [String, String, Boolean]),
|
|
48
53
|
__metadata("design:returntype", Promise)
|
|
49
54
|
], EntityCodeGenerateCommand.prototype, "index", null);
|
|
50
55
|
EntityCodeGenerateCommand = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityCodeGenerateCommand.js","sourceRoot":"","sources":["../../../../src/infrastructure/commands/entity-generator/EntityCodeGenerateCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAmD;AACnD,2CAA0C;AAC1C,+DAA0D;AAInD,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAClC;;;OAGG;IAKG,AAAN,KAAK,CAAC,KAAK,CAMH,UAAkB,EAMlB,UAAkB;
|
|
1
|
+
{"version":3,"file":"EntityCodeGenerateCommand.js","sourceRoot":"","sources":["../../../../src/infrastructure/commands/entity-generator/EntityCodeGenerateCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAmD;AACnD,2CAA0C;AAC1C,+DAA0D;AAInD,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAClC;;;OAGG;IAKG,AAAN,KAAK,CAAC,KAAK,CAMH,UAAkB,EAMlB,UAAkB,EAMtB,eAAyB;QAEzB,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SAC3D;QAED,CAAC,IAAI,yCAAmB,CACpB,UAAU,EACV,UAAU,EACV,IAAI,EACJ,eAAe,CAClB,CAAC,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;CACJ,CAAA;AA/BS;IAJL,IAAA,wBAAO,EAAC;QACL,OAAO,EAAE,6DAA6D;QACtE,QAAQ,EAAE,iEAAiE;KAC9E,CAAC;IAEG,WAAA,IAAA,2BAAU,EAAC;QACR,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,8BAA8B;QACxC,IAAI,EAAE,QAAQ;KACjB,CAAC,CAAA;IAED,WAAA,IAAA,2BAAU,EAAC;QACR,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,6BAA6B;QACvC,IAAI,EAAE,QAAQ;KACjB,CAAC,CAAA;IAED,WAAA,IAAA,2BAAU,EAAC;QACR,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,qCAAqC;QAC/C,IAAI,EAAE,SAAS;KAClB,CAAC,CAAA;;;;sDAaL;AAvCQ,yBAAyB;IADrC,IAAA,mBAAU,GAAE;GACA,yBAAyB,CAwCrC;AAxCY,8DAAyB"}
|
|
@@ -4,9 +4,11 @@ export declare class EntityCodeGenerator {
|
|
|
4
4
|
readonly tableName: string;
|
|
5
5
|
readonly projectRootPath: string;
|
|
6
6
|
readonly modulePath: string;
|
|
7
|
+
readonly onlyReadService: boolean;
|
|
7
8
|
readonly placeholdersValuesMap: Record<string, string>;
|
|
8
|
-
constructor(entityName: string, moduleName: string, rootPath?: string);
|
|
9
|
+
constructor(entityName: string, moduleName: string, rootPath?: string, onlyReadService?: boolean);
|
|
9
10
|
generate(): void;
|
|
11
|
+
private shouldSkipTemplate;
|
|
10
12
|
private generateFileByType;
|
|
11
13
|
private findModulePath;
|
|
12
14
|
private getTableName;
|
|
@@ -11,7 +11,8 @@ const resultPaths = {
|
|
|
11
11
|
repository: 'infrastructure/repositories/%entityName%Repository.ts',
|
|
12
12
|
repositoryInterface: 'domain/interfaces/I%entityName%Repository.ts',
|
|
13
13
|
table: 'infrastructure/tables/%entityName%Table.ts',
|
|
14
|
-
|
|
14
|
+
crudService: 'domain/services/%entityName%Service.ts',
|
|
15
|
+
readService: 'domain/services/%entityName%Service.ts',
|
|
15
16
|
saveDto: 'domain/dtos/%entityName%SaveDto.ts',
|
|
16
17
|
searchDto: 'domain/dtos/%entityName%SearchDto.ts',
|
|
17
18
|
};
|
|
@@ -20,12 +21,13 @@ const templates = {
|
|
|
20
21
|
repository: 'RepositoryTemplate.txt',
|
|
21
22
|
repositoryInterface: 'RepositoryInterfaceTemplate.txt',
|
|
22
23
|
table: 'TableTemplate.txt',
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
readService: 'ReadServiceTemplate.txt',
|
|
25
|
+
crudService: 'CrudServiceTemplate.txt',
|
|
25
26
|
searchDto: 'SearchDtoTemplate.txt',
|
|
27
|
+
saveDto: 'SaveDtoTemplate.txt',
|
|
26
28
|
};
|
|
27
29
|
class EntityCodeGenerator {
|
|
28
|
-
constructor(entityName, moduleName, rootPath = null) {
|
|
30
|
+
constructor(entityName, moduleName, rootPath = null, onlyReadService = false) {
|
|
29
31
|
this.placeholdersValuesMap = {};
|
|
30
32
|
// set first letter in upper case if it's not
|
|
31
33
|
if (entityName[0].toUpperCase() !== entityName[0]) {
|
|
@@ -35,6 +37,7 @@ class EntityCodeGenerator {
|
|
|
35
37
|
this.entityName = entityName;
|
|
36
38
|
}
|
|
37
39
|
this.moduleName = moduleName;
|
|
40
|
+
this.onlyReadService = onlyReadService;
|
|
38
41
|
this.projectRootPath = rootPath || process.cwd();
|
|
39
42
|
this.modulePath = this.findModulePath(moduleName);
|
|
40
43
|
this.tableName = this.getTableName();
|
|
@@ -46,24 +49,39 @@ class EntityCodeGenerator {
|
|
|
46
49
|
generate() {
|
|
47
50
|
const allFileTypes = Object.keys(templates);
|
|
48
51
|
for (const fileType of allFileTypes) {
|
|
52
|
+
if (this.shouldSkipTemplate(fileType)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
49
55
|
this.generateFileByType(fileType);
|
|
50
56
|
}
|
|
51
57
|
}
|
|
58
|
+
shouldSkipTemplate(fileType) {
|
|
59
|
+
const entitiesToSkipIfReadOnly = ['crudService', 'saveDto'];
|
|
60
|
+
const entitiesToSkipIfNotReadOnly = ['readService'];
|
|
61
|
+
if (this.onlyReadService) {
|
|
62
|
+
return entitiesToSkipIfReadOnly.includes(fileType);
|
|
63
|
+
}
|
|
64
|
+
return entitiesToSkipIfNotReadOnly.includes(fileType);
|
|
65
|
+
}
|
|
52
66
|
generateFileByType(fileType) {
|
|
53
67
|
const templatePath = path.resolve(__dirname, 'templates');
|
|
54
68
|
let resultFileContent = fs.readFileSync(path.resolve(templatePath, templates[fileType]), 'utf8');
|
|
55
69
|
for (const placeholder in this.placeholdersValuesMap) {
|
|
56
70
|
resultFileContent = resultFileContent.replace(new RegExp(`${(0, lodash_1.escapeRegExp)(placeholder)}`, 'g'), this.placeholdersValuesMap[placeholder]);
|
|
57
71
|
}
|
|
58
|
-
|
|
72
|
+
const resultFilePath = path.resolve(this.modulePath, resultPaths[fileType].replace(ENTITY_NAME_PLACEHOLDER, this.entityName));
|
|
59
73
|
const resultFileDirPath = path.dirname(resultFilePath);
|
|
60
74
|
if (!fs.existsSync(resultFileDirPath)) {
|
|
61
75
|
fs.mkdirSync(resultFileDirPath, { recursive: true });
|
|
62
76
|
}
|
|
77
|
+
if (fs.existsSync(resultFilePath)) {
|
|
78
|
+
console.log(`File ${resultFilePath} already exists, skipping to avoid overwriting.`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
63
81
|
fs.writeFileSync(resultFilePath, resultFileContent);
|
|
64
82
|
}
|
|
65
83
|
findModulePath(moduleName) {
|
|
66
|
-
|
|
84
|
+
const possibleModulePaths = [
|
|
67
85
|
path.resolve(this.projectRootPath, 'src', moduleName),
|
|
68
86
|
path.resolve(this.projectRootPath, moduleName),
|
|
69
87
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityCodeGenerator.js","sourceRoot":"","sources":["../../../../src/infrastructure/commands/entity-generator/EntityCodeGenerator.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,6BAA6B;AAC7B,mCAA+C;AAE/C,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAC/C,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAE7C,MAAM,WAAW,GAAG;IAChB,KAAK,EAAE,oCAAoC;IAC3C,UAAU,EAAE,uDAAuD;IACnE,mBAAmB,EAAE,8CAA8C;IACnE,KAAK,EAAE,4CAA4C;IACnD,
|
|
1
|
+
{"version":3,"file":"EntityCodeGenerator.js","sourceRoot":"","sources":["../../../../src/infrastructure/commands/entity-generator/EntityCodeGenerator.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,6BAA6B;AAC7B,mCAA+C;AAE/C,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAC/C,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAE7C,MAAM,WAAW,GAAG;IAChB,KAAK,EAAE,oCAAoC;IAC3C,UAAU,EAAE,uDAAuD;IACnE,mBAAmB,EAAE,8CAA8C;IACnE,KAAK,EAAE,4CAA4C;IACnD,WAAW,EAAE,wCAAwC;IACrD,WAAW,EAAE,wCAAwC;IACrD,OAAO,EAAE,oCAAoC;IAC7C,SAAS,EAAE,sCAAsC;CACpD,CAAC;AAEF,MAAM,SAAS,GAAG;IACd,KAAK,EAAE,mBAAmB;IAC1B,UAAU,EAAE,wBAAwB;IACpC,mBAAmB,EAAE,iCAAiC;IACtD,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,yBAAyB;IACtC,WAAW,EAAE,yBAAyB;IACtC,SAAS,EAAE,uBAAuB;IAClC,OAAO,EAAE,qBAAqB;CACjC,CAAC;AAEF,MAAa,mBAAmB;IAe5B,YACI,UAAkB,EAClB,UAAkB,EAClB,WAAmB,IAAI,EACvB,eAAe,GAAG,KAAK;QANlB,0BAAqB,GAA2B,EAAE,CAAC;QAQxD,6CAA6C;QAC7C,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,K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AAE,UAAU,CAAC;YACrD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC;SACjD,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,mBAAmB,EAAE;YACpC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBACrB,OAAO,IAAI,CAAC;aACf;SACJ;QAED,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC/D,CAAC;IAEO,YAAY;QAChB,IAAI,SAAS,GAAG,IAAA,kBAAS,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,MAAM,6BAA6B,GAAG,CAClC,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,CACtC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAElB,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC;QAEtF,IAAI,CAAC,6BAA6B,EAAE;YAChC,SAAS,GAAG,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,SAAS,CAAC;SACjD;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAnID,kDAmIC"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import {Inject, Injectable} from '@nestjs/common';
|
|
1
2
|
import {CrudService} from '@steroidsjs/nest/usecases/services/CrudService';
|
|
2
3
|
import {%entityName%SearchDto} from '../dtos/%entityName%SearchDto';
|
|
3
4
|
import {%entityName%SaveDto} from '../dtos/%entityName%SaveDto';
|
|
4
5
|
import {%entityName%Model} from '../models/%entityName%Model';
|
|
5
6
|
import {I%entityName%Repository} from '../interfaces/I%entityName%Repository';
|
|
6
7
|
|
|
8
|
+
@Injectable()
|
|
7
9
|
export class %entityName%Service extends CrudService<%entityName%Model, %entityName%SearchDto, %entityName%SaveDto> {
|
|
8
10
|
protected modelClass = %entityName%Model;
|
|
9
11
|
|
|
10
12
|
constructor(
|
|
11
13
|
/** %entityName%Repository */
|
|
12
|
-
|
|
14
|
+
@Inject(I%entityName%Repository)
|
|
15
|
+
protected readonly repository: I%entityName%Repository,
|
|
13
16
|
) {
|
|
14
17
|
super();
|
|
15
18
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {Inject, Injectable} from '@nestjs/common';
|
|
2
|
+
import {ReadService} from '@steroidsjs/nest/usecases/services/ReadService';
|
|
3
|
+
import {%entityName%SearchDto} from '../dtos/%entityName%SearchDto';
|
|
4
|
+
import {%entityName%Model} from '../models/%entityName%Model';
|
|
5
|
+
import {I%entityName%Repository} from '../interfaces/I%entityName%Repository';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class %entityName%Service extends ReadService<%entityName%Model, %entityName%SearchDto> {
|
|
9
|
+
protected modelClass = %entityName%Model;
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
/** %entityName%Repository */
|
|
13
|
+
@Inject(I%entityName%Repository)
|
|
14
|
+
protected readonly repository: I%entityName%Repository,
|
|
15
|
+
) {
|
|
16
|
+
super();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {IDeepPartial} from '@steroidsjs/nest/usecases/interfaces/IDeepPartial';
|
|
2
|
-
import {TypeOrmTableFromModel} from '@steroidsjs/nest/infrastructure/decorators/TypeOrmTableFromModel';
|
|
2
|
+
import {TypeOrmTableFromModel} from '@steroidsjs/nest/infrastructure/decorators/typeorm/TypeOrmTableFromModel';
|
|
3
3
|
import {%entityName%Model} from '../../domain/models/%entityName%Model';
|
|
4
4
|
|
|
5
5
|
@TypeOrmTableFromModel(%entityName%Model, '%tableName%')
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IBaseFieldOptions } from './BaseField';
|
|
2
2
|
export interface IEnumFieldOptions extends IBaseFieldOptions {
|
|
3
|
-
enum
|
|
3
|
+
enum: object | string[] | any;
|
|
4
|
+
enumName?: string;
|
|
4
5
|
isEnumConstraintMessage?: string;
|
|
5
6
|
}
|
|
6
|
-
export declare function EnumField(options
|
|
7
|
+
export declare function EnumField(options: IEnumFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -32,7 +32,7 @@ function getValidatorEnum(enumEntity) {
|
|
|
32
32
|
}
|
|
33
33
|
return enumEntity;
|
|
34
34
|
}
|
|
35
|
-
function EnumField(options
|
|
35
|
+
function EnumField(options) {
|
|
36
36
|
return (0, common_1.applyDecorators)(...[
|
|
37
37
|
(0, BaseField_1.BaseField)(options, {
|
|
38
38
|
decoratorName: 'EnumField',
|
|
@@ -41,6 +41,7 @@ function EnumField(options = {}) {
|
|
|
41
41
|
}),
|
|
42
42
|
(0, swagger_1.ApiProperty)({
|
|
43
43
|
enum: getOpenApiEnum(options.enum),
|
|
44
|
+
enumName: options.enumName,
|
|
44
45
|
isArray: options.isArray,
|
|
45
46
|
}),
|
|
46
47
|
options.nullable && (0, class_validator_1.ValidateIf)((object, value) => value !== null && typeof value !== 'undefined'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EnumField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAAmD;AACnD,6CAA4C;AAC5C,2CAAyD;AACzD,4DAAqD;
|
|
1
|
+
{"version":3,"file":"EnumField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EnumField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAAmD;AACnD,6CAA4C;AAC5C,2CAAyD;AACzD,4DAAqD;AAYrD,SAAS,cAAc,CAAC,UAA6C;IACjE,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC3B,OAAO,UAAU,CAAC;KACrB;IAED,IAAI,OAAO,UAAU,KAAK,UAAU,I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I,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC;QACjG,IAAA,wBAAM,EACF,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,EAC9B;YACI,IAAI,EAAE,OAAO,CAAC,OAAO;YACrB,OAAO,EAAE,OAAO,CAAC,uBAAuB,IAAI,2BAA2B;SAC1E,CACJ;KACJ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AArBD,8BAqBC"}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { IBaseFieldOptions } from './BaseField';
|
|
2
|
-
export
|
|
2
|
+
export interface IPasswordFieldOptions extends IBaseFieldOptions {
|
|
3
|
+
minLength?: number;
|
|
4
|
+
minLowercase?: number;
|
|
5
|
+
minUppercase?: number;
|
|
6
|
+
minNumbers?: number;
|
|
7
|
+
minSymbols?: number;
|
|
8
|
+
isStrongPasswordConstraintMessage?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function PasswordField(options?: IPasswordFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -2,15 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PasswordField = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
5
6
|
const BaseField_1 = require("./BaseField");
|
|
6
7
|
function PasswordField(options = {}) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(options, {
|
|
8
|
+
const finalOptions = Object.assign({ label: 'Пароль', minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 0, isStrongPasswordConstraintMessage: 'Ненадёжный пароль' }, options);
|
|
9
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(finalOptions, {
|
|
11
10
|
decoratorName: 'PasswordField',
|
|
12
11
|
appType: 'password',
|
|
13
12
|
jsType: 'string',
|
|
13
|
+
}), (0, class_validator_1.IsStrongPassword)({
|
|
14
|
+
minLength: finalOptions.minLength,
|
|
15
|
+
minLowercase: finalOptions.minLowercase,
|
|
16
|
+
minUppercase: finalOptions.minUppercase,
|
|
17
|
+
minNumbers: finalOptions.minNumbers,
|
|
18
|
+
minSymbols: finalOptions.minSymbols,
|
|
19
|
+
}, {
|
|
20
|
+
each: finalOptions.isArray,
|
|
21
|
+
message: finalOptions.isStrongPasswordConstraintMessage,
|
|
14
22
|
}));
|
|
15
23
|
}
|
|
16
24
|
exports.PasswordField = PasswordField;
|