@rxap/schematic-nestjs 0.0.2-dev.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/CHANGELOG.md +8 -0
- package/GETSTARTED.md +0 -0
- package/GUIDES.md +0 -0
- package/README.md +21 -0
- package/collection.json +74 -0
- package/package.json +67 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -0
- package/src/schematics/crud/index.d.ts +3 -0
- package/src/schematics/crud/index.js +49 -0
- package/src/schematics/crud/index.js.map +1 -0
- package/src/schematics/crud/schema.d.ts +7 -0
- package/src/schematics/crud/schema.js +3 -0
- package/src/schematics/crud/schema.js.map +1 -0
- package/src/schematics/crud/schema.json +17 -0
- package/src/schematics/crud-init/index.d.ts +3 -0
- package/src/schematics/crud-init/index.js +14 -0
- package/src/schematics/crud-init/index.js.map +1 -0
- package/src/schematics/crud-init/schema.d.ts +4 -0
- package/src/schematics/crud-init/schema.js +3 -0
- package/src/schematics/crud-init/schema.js.map +1 -0
- package/src/schematics/crud-init/schema.json +18 -0
- package/src/schematics/crud-service/add-module-export.d.ts +4 -0
- package/src/schematics/crud-service/add-module-export.js +29 -0
- package/src/schematics/crud-service/add-module-export.js.map +1 -0
- package/src/schematics/crud-service/add-module-provider.d.ts +4 -0
- package/src/schematics/crud-service/add-module-provider.js +29 -0
- package/src/schematics/crud-service/add-module-provider.js.map +1 -0
- package/src/schematics/crud-service/coerce-class-method.d.ts +2 -0
- package/src/schematics/crud-service/coerce-class-method.js +10 -0
- package/src/schematics/crud-service/coerce-class-method.js.map +1 -0
- package/src/schematics/crud-service/coerce-class-property.d.ts +2 -0
- package/src/schematics/crud-service/coerce-class-property.js +10 -0
- package/src/schematics/crud-service/coerce-class-property.js.map +1 -0
- package/src/schematics/crud-service/coerce-collection-enum.d.ts +4 -0
- package/src/schematics/crud-service/coerce-collection-enum.js +29 -0
- package/src/schematics/crud-service/coerce-collection-enum.js.map +1 -0
- package/src/schematics/crud-service/coerce-module-class.d.ts +2 -0
- package/src/schematics/crud-service/coerce-module-class.js +32 -0
- package/src/schematics/crud-service/coerce-module-class.js.map +1 -0
- package/src/schematics/crud-service/coerce-source-file-rule.d.ts +11 -0
- package/src/schematics/crud-service/coerce-source-file-rule.js +29 -0
- package/src/schematics/crud-service/coerce-source-file-rule.js.map +1 -0
- package/src/schematics/crud-service/crud-class/create-method.d.ts +3 -0
- package/src/schematics/crud-service/crud-class/create-method.js +69 -0
- package/src/schematics/crud-service/crud-class/create-method.js.map +1 -0
- package/src/schematics/crud-service/crud-class/delete-method.d.ts +3 -0
- package/src/schematics/crud-service/crud-class/delete-method.js +46 -0
- package/src/schematics/crud-service/crud-class/delete-method.js.map +1 -0
- package/src/schematics/crud-service/crud-class/exists-method.d.ts +3 -0
- package/src/schematics/crud-service/crud-class/exists-method.js +46 -0
- package/src/schematics/crud-service/crud-class/exists-method.js.map +1 -0
- package/src/schematics/crud-service/crud-class/find-in-group-method.d.ts +3 -0
- package/src/schematics/crud-service/crud-class/find-in-group-method.js +37 -0
- package/src/schematics/crud-service/crud-class/find-in-group-method.js.map +1 -0
- package/src/schematics/crud-service/crud-class/find-method.d.ts +3 -0
- package/src/schematics/crud-service/crud-class/find-method.js +46 -0
- package/src/schematics/crud-service/crud-class/find-method.js.map +1 -0
- package/src/schematics/crud-service/crud-class/get-method.d.ts +3 -0
- package/src/schematics/crud-service/crud-class/get-method.js +52 -0
- package/src/schematics/crud-service/crud-class/get-method.js.map +1 -0
- package/src/schematics/crud-service/crud-class/update-field-method.d.ts +3 -0
- package/src/schematics/crud-service/crud-class/update-field-method.js +68 -0
- package/src/schematics/crud-service/crud-class/update-field-method.js.map +1 -0
- package/src/schematics/crud-service/crud-class/update-method.d.ts +3 -0
- package/src/schematics/crud-service/crud-class/update-method.js +59 -0
- package/src/schematics/crud-service/crud-class/update-method.js.map +1 -0
- package/src/schematics/crud-service/crud-class.d.ts +3 -0
- package/src/schematics/crud-service/crud-class.js +125 -0
- package/src/schematics/crud-service/crud-class.js.map +1 -0
- package/src/schematics/crud-service/dto-class/create-dto-class.d.ts +3 -0
- package/src/schematics/crud-service/dto-class/create-dto-class.js +26 -0
- package/src/schematics/crud-service/dto-class/create-dto-class.js.map +1 -0
- package/src/schematics/crud-service/dto-class/dto-class.d.ts +3 -0
- package/src/schematics/crud-service/dto-class/dto-class.js +133 -0
- package/src/schematics/crud-service/dto-class/dto-class.js.map +1 -0
- package/src/schematics/crud-service/dto-class/update-dto-class.d.ts +3 -0
- package/src/schematics/crud-service/dto-class/update-dto-class.js +28 -0
- package/src/schematics/crud-service/dto-class/update-dto-class.js.map +1 -0
- package/src/schematics/crud-service/index.d.ts +3 -0
- package/src/schematics/crud-service/index.js +215 -0
- package/src/schematics/crud-service/index.js.map +1 -0
- package/src/schematics/crud-service/options.d.ts +11 -0
- package/src/schematics/crud-service/options.js +3 -0
- package/src/schematics/crud-service/options.js.map +1 -0
- package/src/schematics/crud-service/schema.d.ts +53 -0
- package/src/schematics/crud-service/schema.js +3 -0
- package/src/schematics/crud-service/schema.js.map +1 -0
- package/src/schematics/crud-service/schema.json +57 -0
- package/src/schematics/feature-microservice/index.d.ts +11 -0
- package/src/schematics/feature-microservice/index.js +65 -0
- package/src/schematics/feature-microservice/index.js.map +1 -0
- package/src/schematics/feature-microservice/schema.d.ts +15 -0
- package/src/schematics/feature-microservice/schema.json +69 -0
- package/src/schematics/frontend-microservice/index.d.ts +11 -0
- package/src/schematics/frontend-microservice/index.js +61 -0
- package/src/schematics/frontend-microservice/index.js.map +1 -0
- package/src/schematics/frontend-microservice/schema.d.ts +16 -0
- package/src/schematics/frontend-microservice/schema.json +75 -0
- package/src/schematics/health-indicator/add-health-endpoint.d.ts +2 -0
- package/src/schematics/health-indicator/add-health-endpoint.js +58 -0
- package/src/schematics/health-indicator/add-health-endpoint.js.map +1 -0
- package/src/schematics/health-indicator/add-health-indicator.d.ts +2 -0
- package/src/schematics/health-indicator/add-health-indicator.js +61 -0
- package/src/schematics/health-indicator/add-health-indicator.js.map +1 -0
- package/src/schematics/health-indicator/add-to-global-health-endpoint.d.ts +2 -0
- package/src/schematics/health-indicator/add-to-global-health-endpoint.js +54 -0
- package/src/schematics/health-indicator/add-to-global-health-endpoint.js.map +1 -0
- package/src/schematics/health-indicator/coerce-health-controller.d.ts +2 -0
- package/src/schematics/health-indicator/coerce-health-controller.js +25 -0
- package/src/schematics/health-indicator/coerce-health-controller.js.map +1 -0
- package/src/schematics/health-indicator/coerce-health-module.d.ts +2 -0
- package/src/schematics/health-indicator/coerce-health-module.js +48 -0
- package/src/schematics/health-indicator/coerce-health-module.js.map +1 -0
- package/src/schematics/health-indicator/index.d.ts +3 -0
- package/src/schematics/health-indicator/index.js +29 -0
- package/src/schematics/health-indicator/index.js.map +1 -0
- package/src/schematics/health-indicator/schema.d.ts +4 -0
- package/src/schematics/health-indicator/schema.json +29 -0
- package/src/schematics/health-indicator-init/index.d.ts +3 -0
- package/src/schematics/health-indicator-init/index.js +23 -0
- package/src/schematics/health-indicator-init/index.js.map +1 -0
- package/src/schematics/health-indicator-init/schema.d.ts +3 -0
- package/src/schematics/health-indicator-init/schema.json +19 -0
- package/src/schematics/init/files/Dockerfile.template +24 -0
- package/src/schematics/init/files/healthcheck.js.template +35 -0
- package/src/schematics/init/files/main.ts.template +77 -0
- package/src/schematics/init/index.d.ts +6 -0
- package/src/schematics/init/index.js +463 -0
- package/src/schematics/init/index.js.map +1 -0
- package/src/schematics/init/schema.d.ts +23 -0
- package/src/schematics/init/schema.json +103 -0
- package/src/schematics/jwt/index.d.ts +2 -0
- package/src/schematics/jwt/index.js +46 -0
- package/src/schematics/jwt/index.js.map +1 -0
- package/src/schematics/jwt/schema.d.ts +3 -0
- package/src/schematics/jwt/schema.json +15 -0
- package/src/schematics/microservice/index.d.ts +12 -0
- package/src/schematics/microservice/index.js +117 -0
- package/src/schematics/microservice/index.js.map +1 -0
- package/src/schematics/microservice/schema.d.ts +15 -0
- package/src/schematics/microservice/schema.json +69 -0
- package/src/schematics/open-api/index.d.ts +2 -0
- package/src/schematics/open-api/index.js +39 -0
- package/src/schematics/open-api/index.js.map +1 -0
- package/src/schematics/open-api/schema.d.ts +3 -0
- package/src/schematics/open-api/schema.json +15 -0
- package/src/schematics/sentry/index.d.ts +3 -0
- package/src/schematics/sentry/index.js +129 -0
- package/src/schematics/sentry/index.js.map +1 -0
- package/src/schematics/sentry/schema.d.ts +5 -0
- package/src/schematics/sentry/schema.json +27 -0
- package/src/schematics/swagger/files/environments/environment.swagger.ts.template +7 -0
- package/src/schematics/swagger/files/swagger.ts.template +19 -0
- package/src/schematics/swagger/index.d.ts +3 -0
- package/src/schematics/swagger/index.js +88 -0
- package/src/schematics/swagger/index.js.map +1 -0
- package/src/schematics/swagger/schema.d.ts +4 -0
- package/src/schematics/swagger/schema.json +19 -0
- package/src/schematics/validator/index.d.ts +3 -0
- package/src/schematics/validator/index.js +15 -0
- package/src/schematics/validator/index.js.map +1 -0
- package/src/schematics/validator/schema.d.ts +3 -0
- package/src/schematics/validator/schema.json +19 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddToGlobalHealthEndpoint = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const core_1 = require("@angular-devkit/core");
|
|
6
|
+
const schematics_ts_morph_1 = require("@rxap/schematics-ts-morph");
|
|
7
|
+
const { dasherize, classify, camelize, decamelize } = core_1.strings;
|
|
8
|
+
function AddToGlobalHealthEndpoint(sourceFile, name) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const classDeclaration = sourceFile.getClass('HealthController');
|
|
11
|
+
if (!classDeclaration) {
|
|
12
|
+
throw new Error('FATAL: could not find the HealthController class!');
|
|
13
|
+
}
|
|
14
|
+
const healthIndicatorClass = `${classify(name)}HealthIndicator`;
|
|
15
|
+
const methodDeclaration = (0, schematics_ts_morph_1.CoerceClassMethod)(classDeclaration, 'healthCheck', {
|
|
16
|
+
scope: ts_morph_1.Scope.Public,
|
|
17
|
+
returnType: 'Promise<HealthCheckResult>',
|
|
18
|
+
statements: [
|
|
19
|
+
w => {
|
|
20
|
+
w.writeLine('return this.health.check([');
|
|
21
|
+
w.write(']);');
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
decorators: [
|
|
25
|
+
{
|
|
26
|
+
name: 'Get',
|
|
27
|
+
arguments: [],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'HealthCheck',
|
|
31
|
+
arguments: [],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
sourceFile.addImportDeclarations([
|
|
36
|
+
{
|
|
37
|
+
moduleSpecifier: '@nestjs/terminus',
|
|
38
|
+
namedImports: ['HealthCheck', 'HealthCheckResult'],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
moduleSpecifier: '@nestjs/common',
|
|
42
|
+
namedImports: ['Get'],
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
const statement = methodDeclaration.getStatements().find(e => e.getFullText().match(/return this\.health\.check/));
|
|
46
|
+
const array = (_b = (_a = statement === null || statement === void 0 ? void 0 : statement.getChildAtIndex(1)) === null || _a === void 0 ? void 0 : _a.getChildAtIndex(2)) === null || _b === void 0 ? void 0 : _b.getFirstChild();
|
|
47
|
+
if (array instanceof ts_morph_1.ArrayLiteralExpression) {
|
|
48
|
+
array.addElement(w => {
|
|
49
|
+
w.write(`async () => this.${camelize(healthIndicatorClass)}.isHealthy()`);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.AddToGlobalHealthEndpoint = AddToGlobalHealthEndpoint;
|
|
54
|
+
//# sourceMappingURL=add-to-global-health-endpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-to-global-health-endpoint.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/nestjs/src/schematics/health-indicator/add-to-global-health-endpoint.ts"],"names":[],"mappings":";;;AAAA,uCAKkB;AAClB,+CAA+C;AAC/C,mEAA8D;AAE9D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,cAAO,CAAC;AAE9D,SAAgB,yBAAyB,CACvC,UAAsB,EACtB,IAAY;;IAGZ,MAAM,gBAAgB,GAAG,UAAU,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAEjE,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IAED,MAAM,oBAAoB,GAAG,GAAI,QAAQ,CAAC,IAAI,CAAE,iBAAiB,CAAC;IAElE,MAAM,iBAAiB,GAAsB,IAAA,uCAAiB,EAC5D,gBAAgB,EAChB,aAAa,EACb;QACE,KAAK,EAAE,gBAAK,CAAC,MAAM;QACnB,UAAU,EAAE,4BAA4B;QACxC,UAAU,EAAE;YACV,CAAC,CAAC,EAAE;gBACF,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;gBAC1C,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;SACF;QACD,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,KAAK;gBACX,SAAS,EAAE,EAAE;aACd;YACD;gBACE,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,EAAE;aACd;SACF;KACF,CACF,CAAC;IAEF,UAAU,CAAC,qBAAqB,CAAC;QAC/B;YACE,eAAe,EAAE,kBAAkB;YACnC,YAAY,EAAE,CAAE,aAAa,EAAE,mBAAmB,CAAE;SACrD;QACD;YACE,eAAe,EAAE,gBAAgB;YACjC,YAAY,EAAE,CAAE,KAAK,CAAE;SACxB;KACF,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,iBAAiB,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;IAEnH,MAAM,KAAK,GAAG,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,eAAe,CAAC,CAAC,CAAC,0CAAE,eAAe,CAAC,CAAC,CAAC,0CAAE,aAAa,EAAE,CAAC;IAEjF,IAAI,KAAK,YAAY,iCAAsB,EAAE;QAC3C,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;YACnB,CAAC,CAAC,KAAK,CAAC,oBAAqB,QAAQ,CAAC,oBAAoB,CAAE,cAAc,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;KACJ;AAEH,CAAC;AA3DD,8DA2DC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceHealthController = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const schematics_ts_morph_1 = require("@rxap/schematics-ts-morph");
|
|
6
|
+
function CoerceHealthController(project) {
|
|
7
|
+
const sourceFile = (0, schematics_ts_morph_1.CoerceSourceFile)(project, '/app/health/health.controller.ts');
|
|
8
|
+
(0, schematics_ts_morph_1.AddNestController)(project, 'health', {
|
|
9
|
+
sourceFile,
|
|
10
|
+
});
|
|
11
|
+
(0, schematics_ts_morph_1.AddDependencyInjection)(sourceFile, {
|
|
12
|
+
injectionToken: 'HealthCheckService',
|
|
13
|
+
parameterName: 'health',
|
|
14
|
+
scope: ts_morph_1.Scope.Private,
|
|
15
|
+
module: schematics_ts_morph_1.Module.NEST,
|
|
16
|
+
}, [
|
|
17
|
+
{
|
|
18
|
+
namedImports: ['HealthCheckService'],
|
|
19
|
+
moduleSpecifier: '@nestjs/terminus',
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
return sourceFile;
|
|
23
|
+
}
|
|
24
|
+
exports.CoerceHealthController = CoerceHealthController;
|
|
25
|
+
//# sourceMappingURL=coerce-health-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-health-controller.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/nestjs/src/schematics/health-indicator/coerce-health-controller.ts"],"names":[],"mappings":";;;AAAA,uCAIkB;AAClB,mEAKmC;AAEnC,SAAgB,sBAAsB,CAAC,OAAgB;IAErD,MAAM,UAAU,GAAG,IAAA,sCAAgB,EAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC;IAEjF,IAAA,uCAAiB,EACf,OAAO,EACP,QAAQ,EACR;QACE,UAAU;KACX,CACF,CAAC;IAEF,IAAA,4CAAsB,EAAC,UAAU,EAAE;QACjC,cAAc,EAAE,oBAAoB;QACpC,aAAa,EAAE,QAAQ;QACvB,KAAK,EAAE,gBAAK,CAAC,OAAO;QACpB,MAAM,EAAE,4BAAM,CAAC,IAAI;KACpB,EAAE;QACD;YACE,YAAY,EAAE,CAAE,oBAAoB,CAAE;YACtC,eAAe,EAAE,kBAAkB;SACpC;KACF,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AAEpB,CAAC;AA1BD,wDA0BC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceHealthModule = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const schematics_ts_morph_1 = require("@rxap/schematics-ts-morph");
|
|
6
|
+
function CoerceHealthModule(project) {
|
|
7
|
+
const sourceFile = (0, schematics_ts_morph_1.CoerceSourceFile)(project, '/app/health/health.module.ts');
|
|
8
|
+
(0, schematics_ts_morph_1.CoerceClass)(sourceFile, 'HealthModule', {
|
|
9
|
+
decorators: [
|
|
10
|
+
{
|
|
11
|
+
name: 'Module',
|
|
12
|
+
arguments: [
|
|
13
|
+
ts_morph_1.Writers.object({}),
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
isExported: true,
|
|
18
|
+
});
|
|
19
|
+
(0, schematics_ts_morph_1.AddNestModuleImport)(sourceFile, 'TerminusModule', [
|
|
20
|
+
{
|
|
21
|
+
moduleSpecifier: '@nestjs/terminus',
|
|
22
|
+
namedImports: ['TerminusModule'],
|
|
23
|
+
},
|
|
24
|
+
]);
|
|
25
|
+
(0, schematics_ts_morph_1.AddNestModuleProvider)(sourceFile, 'Logger', [
|
|
26
|
+
{
|
|
27
|
+
moduleSpecifier: '@nestjs/common',
|
|
28
|
+
namedImports: ['Logger'],
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
sourceFile.addImportDeclarations([
|
|
32
|
+
{
|
|
33
|
+
moduleSpecifier: '@nestjs/common',
|
|
34
|
+
namedImports: ['Module'],
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
|
+
const appSourceFile = (0, schematics_ts_morph_1.FindNestModuleSourceFile)(project, '/app');
|
|
38
|
+
if (appSourceFile) {
|
|
39
|
+
(0, schematics_ts_morph_1.AddNestModuleImport)(appSourceFile, 'HealthModule', [
|
|
40
|
+
{
|
|
41
|
+
namedImports: ['HealthModule'],
|
|
42
|
+
moduleSpecifier: './health/health.module',
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.CoerceHealthModule = CoerceHealthModule;
|
|
48
|
+
//# sourceMappingURL=coerce-health-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-health-module.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/nestjs/src/schematics/health-indicator/coerce-health-module.ts"],"names":[],"mappings":";;;AAAA,uCAGkB;AAClB,mEAMmC;AAEnC,SAAgB,kBAAkB,CAAC,OAAgB;IAEjD,MAAM,UAAU,GAAG,IAAA,sCAAgB,EAAC,OAAO,EAAE,8BAA8B,CAAC,CAAC;IAE7E,IAAA,iCAAW,EAAC,UAAU,EAAE,cAAc,EAAE;QACtC,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,QAAQ;gBACd,SAAS,EAAE;oBACT,kBAAO,CAAC,MAAM,CAAC,EAAE,CAAC;iBACnB;aACF;SACF;QACD,UAAU,EAAE,IAAI;KACjB,CAAC,CAAC;IAEH,IAAA,yCAAmB,EAAC,UAAU,EAAE,gBAAgB,EAAE;QAChD;YACE,eAAe,EAAE,kBAAkB;YACnC,YAAY,EAAE,CAAE,gBAAgB,CAAE;SACnC;KACF,CAAC,CAAC;IAEH,IAAA,2CAAqB,EAAC,UAAU,EAAE,QAAQ,EAAE;QAC1C;YACE,eAAe,EAAE,gBAAgB;YACjC,YAAY,EAAE,CAAE,QAAQ,CAAE;SAC3B;KACF,CAAC,CAAC;IAEH,UAAU,CAAC,qBAAqB,CAAC;QAC/B;YACE,eAAe,EAAE,gBAAgB;YACjC,YAAY,EAAE,CAAE,QAAQ,CAAE;SAC3B;KACF,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,IAAA,8CAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAEhE,IAAI,aAAa,EAAE;QAEjB,IAAA,yCAAmB,EACjB,aAAa,EACb,cAAc,EACd;YACE;gBACE,YAAY,EAAE,CAAE,cAAc,CAAE;gBAChC,eAAe,EAAE,wBAAwB;aAC1C;SACF,CACF,CAAC;KAEH;AAEH,CAAC;AAtDD,gDAsDC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
4
|
+
const schematics_ts_morph_1 = require("@rxap/schematics-ts-morph");
|
|
5
|
+
const schematics_utilities_1 = require("@rxap/schematics-utilities");
|
|
6
|
+
const add_health_endpoint_1 = require("./add-health-endpoint");
|
|
7
|
+
const add_health_indicator_1 = require("./add-health-indicator");
|
|
8
|
+
const add_to_global_health_endpoint_1 = require("./add-to-global-health-endpoint");
|
|
9
|
+
const coerce_health_controller_1 = require("./coerce-health-controller");
|
|
10
|
+
const coerce_health_module_1 = require("./coerce-health-module");
|
|
11
|
+
function default_1(options) {
|
|
12
|
+
return () => {
|
|
13
|
+
return (0, schematics_1.chain)([
|
|
14
|
+
(0, schematics_ts_morph_1.TsMorphNestProjectTransformRule)({
|
|
15
|
+
project: options.project,
|
|
16
|
+
}, project => {
|
|
17
|
+
(0, coerce_health_module_1.CoerceHealthModule)(project);
|
|
18
|
+
const controllerSourceFile = (0, coerce_health_controller_1.CoerceHealthController)(project);
|
|
19
|
+
(0, add_health_indicator_1.AddHealthIndicator)(project, options.name);
|
|
20
|
+
(0, add_health_endpoint_1.AddHealthEndpoint)(controllerSourceFile, options.name);
|
|
21
|
+
(0, add_to_global_health_endpoint_1.AddToGlobalHealthEndpoint)(controllerSourceFile, options.name);
|
|
22
|
+
}),
|
|
23
|
+
(0, schematics_utilities_1.AddPackageJsonDependencyRule)('@nestjs/terminus', 'latest', { soft: true }),
|
|
24
|
+
(0, schematics_utilities_1.InstallNodePackages)(),
|
|
25
|
+
]);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.default = default_1;
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/nestjs/src/schematics/health-indicator/index.ts"],"names":[],"mappings":";;AAAA,2DAGoC;AACpC,mEAA4E;AAC5E,qEAGoC;AACpC,+DAA0D;AAC1D,iEAA4D;AAC5D,mFAA4E;AAC5E,yEAAoE;AACpE,iEAA4D;AAI5D,mBAAyB,OAA8B;IAErD,OAAO,GAAG,EAAE;QACV,OAAO,IAAA,kBAAK,EAAC;YACX,IAAA,qDAA+B,EAAC;gBAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,EAAE,OAAO,CAAC,EAAE;gBACX,IAAA,yCAAkB,EAAC,OAAO,CAAC,CAAC;gBAC5B,MAAM,oBAAoB,GAAG,IAAA,iDAAsB,EAAC,OAAO,CAAC,CAAC;gBAC7D,IAAA,yCAAkB,EAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC1C,IAAA,uCAAiB,EAAC,oBAAoB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gBACtD,IAAA,yDAAyB,EAAC,oBAAoB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;YAChE,CAAC,CAAC;YACF,IAAA,mDAA4B,EAAC,kBAAkB,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAC1E,IAAA,0CAAmB,GAAE;SACtB,CAAC,CAAC;IACL,CAAC,CAAC;AAEJ,CAAC;AAlBD,4BAkBC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "nest-health-indicator",
|
|
4
|
+
"title": "HealthIndicator",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the health indicator class",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "What name would you like to use for the health indicator?"
|
|
15
|
+
},
|
|
16
|
+
"project": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The name of the project.",
|
|
19
|
+
"$default": {
|
|
20
|
+
"$source": "projectName"
|
|
21
|
+
},
|
|
22
|
+
"x-prompt": "For which project should the health indicator be added?"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": [
|
|
26
|
+
"name",
|
|
27
|
+
"project"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
4
|
+
const schematics_ts_morph_1 = require("@rxap/schematics-ts-morph");
|
|
5
|
+
const schematics_utilities_1 = require("@rxap/schematics-utilities");
|
|
6
|
+
const coerce_health_controller_1 = require("../health-indicator/coerce-health-controller");
|
|
7
|
+
const coerce_health_module_1 = require("../health-indicator/coerce-health-module");
|
|
8
|
+
function default_1(options) {
|
|
9
|
+
return () => {
|
|
10
|
+
return (0, schematics_1.chain)([
|
|
11
|
+
(0, schematics_ts_morph_1.TsMorphNestProjectTransformRule)({
|
|
12
|
+
project: options.project,
|
|
13
|
+
}, project => {
|
|
14
|
+
(0, coerce_health_module_1.CoerceHealthModule)(project);
|
|
15
|
+
(0, coerce_health_controller_1.CoerceHealthController)(project);
|
|
16
|
+
}),
|
|
17
|
+
(0, schematics_utilities_1.AddPackageJsonDependencyRule)('@nestjs/terminus', 'latest', { soft: true }),
|
|
18
|
+
(0, schematics_utilities_1.InstallNodePackages)(),
|
|
19
|
+
]);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.default = default_1;
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/nestjs/src/schematics/health-indicator-init/index.ts"],"names":[],"mappings":";;AAAA,2DAGoC;AACpC,mEAA4E;AAC5E,qEAGoC;AACpC,2FAAsF;AACtF,mFAA8E;AAI9E,mBAAyB,OAAkC;IAEzD,OAAO,GAAG,EAAE;QACV,OAAO,IAAA,kBAAK,EAAC;YACX,IAAA,qDAA+B,EAAC;gBAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,EAAE,OAAO,CAAC,EAAE;gBACX,IAAA,yCAAkB,EAAC,OAAO,CAAC,CAAC;gBAC5B,IAAA,iDAAsB,EAAC,OAAO,CAAC,CAAC;YAClC,CAAC,CAAC;YACF,IAAA,mDAA4B,EAAC,kBAAkB,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAC1E,IAAA,0CAAmB,GAAE;SACtB,CAAC,CAAC;IACL,CAAC,CAAC;AAEJ,CAAC;AAfD,4BAeC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "nest-health-indicator",
|
|
4
|
+
"title": "HealthIndicator",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the project.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "projectName"
|
|
12
|
+
},
|
|
13
|
+
"x-prompt": "For which project should the health indicator module be initialized?"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"required": [
|
|
17
|
+
"project"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
FROM node:18.17-alpine
|
|
2
|
+
# FROM node:18.17 # use if the mongo memory server is used
|
|
3
|
+
|
|
4
|
+
RUN apk add --no-cache git g++ make python3
|
|
5
|
+
|
|
6
|
+
RUN mkdir /app
|
|
7
|
+
|
|
8
|
+
WORKDIR /app
|
|
9
|
+
|
|
10
|
+
COPY package.json /app
|
|
11
|
+
|
|
12
|
+
RUN yarn && yarn cache clean
|
|
13
|
+
|
|
14
|
+
COPY . /app
|
|
15
|
+
|
|
16
|
+
ENV PORT=3000
|
|
17
|
+
<% if (apiPrefix) { %>
|
|
18
|
+
ENV GLOBAL_API_PREFIX="<%= apiPrefix %>"
|
|
19
|
+
<% } %>
|
|
20
|
+
EXPOSE 3000
|
|
21
|
+
|
|
22
|
+
HEALTHCHECK CMD node healthcheck.js > /dev/null || exit 1
|
|
23
|
+
|
|
24
|
+
CMD [ "node", "/app/main.js" ]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const http = require('http');
|
|
2
|
+
|
|
3
|
+
let path = '/';
|
|
4
|
+
|
|
5
|
+
if (process.env.HEALTHCHECK_PATH) {
|
|
6
|
+
path = process.env.HEALTHCHECK_PATH;
|
|
7
|
+
} else {
|
|
8
|
+
if (process.env.GLOBAL_API_PREFIX) {
|
|
9
|
+
path = '/' + process.env.GLOBAL_API_PREFIX + '/'
|
|
10
|
+
}
|
|
11
|
+
<% if (healthIndicator) { %>path += 'health';<% } %>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const options = {
|
|
15
|
+
host : "127.0.0.1",
|
|
16
|
+
port: process.env.PORT ?? <%= port %>,
|
|
17
|
+
path,
|
|
18
|
+
timeout : 30000
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const request = http.request(options, (res) => {
|
|
22
|
+
console.log(`STATUS: ${res.statusCode}`);
|
|
23
|
+
if (res.statusCode === 200) {
|
|
24
|
+
process.exit(0);
|
|
25
|
+
} else {
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
request.on('error', function(err) {
|
|
31
|
+
console.log(`ERROR: ${err.message}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
request.end();
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<% if (validator) { %>
|
|
2
|
+
import { ValidationPipe, HttpStatus } from '@nestjs/common';
|
|
3
|
+
import { ValidationHttpException, validatorOptions, classTransformOptions } from '@rxap/nest-utilities';
|
|
4
|
+
<% } %>
|
|
5
|
+
import { Monolithic } from '@rxap/nest-server';
|
|
6
|
+
import * as cookieParser from 'cookie-parser';
|
|
7
|
+
<% if (google) { %>
|
|
8
|
+
import { WinstonModule } from 'nest-winston';
|
|
9
|
+
import { WinstonFactory } from '@rxap/nest-google';
|
|
10
|
+
<% } %>
|
|
11
|
+
<% if (sentry) { %>
|
|
12
|
+
import { SentryLogger } from '@rxap/nest-sentry';
|
|
13
|
+
<% } %>
|
|
14
|
+
import { environment } from './environments/environment';
|
|
15
|
+
import { AppModule } from './app/app.module';
|
|
16
|
+
<% if (platform === "express") { %>
|
|
17
|
+
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
18
|
+
import helmet from 'helmet';
|
|
19
|
+
<% } else if (platform === "fastify") { %>
|
|
20
|
+
import { NestFastifyApplication } from '@nestjs/platform-fastify';
|
|
21
|
+
import helmet from '@fastify/helmet'
|
|
22
|
+
<% } %>
|
|
23
|
+
import { NestApplicationOptions } from '@nestjs/common';
|
|
24
|
+
|
|
25
|
+
<% if (platform === "express") { %>
|
|
26
|
+
const server = new Monolithic<NestApplicationOptions, NestExpressApplication>(AppModule, environment, { bufferLogs: true });
|
|
27
|
+
<% } else if (platform === "fastify") { %>
|
|
28
|
+
const server = new Monolithic<NestApplicationOptions, NestFastifyApplication>(AppModule, environment, { bufferLogs: true });
|
|
29
|
+
<% } %>
|
|
30
|
+
<% if (google) { %>
|
|
31
|
+
server.before(options => options.logger = WinstonModule.createLogger(WinstonFactory()));
|
|
32
|
+
<% } %>
|
|
33
|
+
<% if (sentry) { %>
|
|
34
|
+
server.after((app, config) => {
|
|
35
|
+
if (config.get('SENTRY_ENABLED')) {
|
|
36
|
+
app.useLogger(app.get(SentryLogger))
|
|
37
|
+
} else {
|
|
38
|
+
app.useLogger(new RxapLogger());
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
<% } else { %>
|
|
42
|
+
server.after(app => app.useLogger(new RxapLogger()));
|
|
43
|
+
<% } %>
|
|
44
|
+
|
|
45
|
+
server.after(app => app.enableCors({
|
|
46
|
+
credentials: true,
|
|
47
|
+
origin: true,
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
server.after((app, config) => app.use(cookieParser(config.get('cookieSecret'))));
|
|
51
|
+
|
|
52
|
+
<% if (platform === "express") { %>
|
|
53
|
+
/**
|
|
54
|
+
* Note that applying helmet as global or registering it must come before other calls to app.use() or setup functions
|
|
55
|
+
* that may call app.use(). This is due to the way the underlying platform (i.e., Express or Fastify) works, where the
|
|
56
|
+
* order that middleware/routes are defined matters. If you use middleware like helmet or cors after you define a route,
|
|
57
|
+
* then that middleware will not apply to that route, it will only apply to routes defined after the middleware.
|
|
58
|
+
*/
|
|
59
|
+
server.after(app => app.use(helmet()));
|
|
60
|
+
<% } else if (platform === "fastify") { %>
|
|
61
|
+
/**
|
|
62
|
+
* If you are getting the This expression is not callable error while trying to import Helmet, you very likely have the
|
|
63
|
+
* allowSyntheticDefaultImports and esModuleInterop options set to true in your project's tsconfig.json file. If that's
|
|
64
|
+
* the case, change the import statement to: import helmet from 'helmet' instead.
|
|
65
|
+
*/
|
|
66
|
+
server.after(app => app.register(helmet));
|
|
67
|
+
<% } %>
|
|
68
|
+
<% if (validator) { %>
|
|
69
|
+
server.after(app => app.useGlobalPipes(new ValidationPipe({
|
|
70
|
+
...validatorOptions,
|
|
71
|
+
transform: true,
|
|
72
|
+
transformOptions: classTransformOptions,
|
|
73
|
+
enableDebugMessages: !environment.production,
|
|
74
|
+
exceptionFactory: errors => new ValidationHttpException(errors, HttpStatus.BAD_REQUEST)
|
|
75
|
+
})));
|
|
76
|
+
<% } %>
|
|
77
|
+
server.bootstrap().catch(e => console.error('Server bootstrap failed: ' + e.message));
|