@kominal/common-nestjs 0.0.16 → 0.0.17
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/executables/bootstrap.d.ts +1 -0
- package/executables/bootstrap.js +38 -0
- package/executables/bootstrap.js.map +1 -0
- package/executables/common-app.module.d.ts +4 -0
- package/executables/common-app.module.js +12 -0
- package/executables/common-app.module.js.map +1 -0
- package/helpers/exception-filter.d.ts +1 -1
- package/helpers/exception-filter.js +5 -5
- package/helpers/exception-filter.js.map +1 -1
- package/helpers/logger.d.ts +1 -1
- package/helpers/logger.js +5 -5
- package/helpers/logger.js.map +1 -1
- package/middlewares/json-body.middleware.d.ts +5 -0
- package/middlewares/json-body.middleware.js +21 -0
- package/middlewares/json-body.middleware.js.map +1 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function bootstrap(module: any): Promise<void>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bootstrap = bootstrap;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const core_1 = require("@nestjs/core");
|
|
6
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const process_1 = require("process");
|
|
9
|
+
const exception_filter_1 = require("../helpers/exception-filter");
|
|
10
|
+
const logger_1 = require("../helpers/logger");
|
|
11
|
+
process.on('uncaughtException', (exception) => {
|
|
12
|
+
console.log(exception);
|
|
13
|
+
});
|
|
14
|
+
async function bootstrap(module) {
|
|
15
|
+
const app = await core_1.NestFactory.create(module, {
|
|
16
|
+
logger: new logger_1.CommonLogger(),
|
|
17
|
+
cors: { origin: '*' },
|
|
18
|
+
bodyParser: false,
|
|
19
|
+
});
|
|
20
|
+
app.useGlobalPipes(new common_1.ValidationPipe());
|
|
21
|
+
app.useGlobalFilters(new exception_filter_1.CommonExceptionFilter());
|
|
22
|
+
app.enableCors();
|
|
23
|
+
const config = new swagger_1.DocumentBuilder()
|
|
24
|
+
.setTitle('Core')
|
|
25
|
+
.addServer('/api/core', 'Current installation')
|
|
26
|
+
.addBearerAuth()
|
|
27
|
+
.build();
|
|
28
|
+
const document = swagger_1.SwaggerModule.createDocument(app, config);
|
|
29
|
+
swagger_1.SwaggerModule.setup('api', app, document);
|
|
30
|
+
if (process.env.GENERATE_SWAGGER) {
|
|
31
|
+
(0, fs_1.writeFileSync)('swagger.json', JSON.stringify(document));
|
|
32
|
+
(0, process_1.exit)(0);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
await app.listen(3000);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/executables/bootstrap.ts"],"names":[],"mappings":";;AAYA,8BAyBC;AArCD,2CAAgD;AAChD,uCAA2C;AAC3C,6CAAiE;AACjE,2BAAmC;AACnC,qCAA+B;AAC/B,kEAAoE;AACpE,8CAAiD;AAEjD,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,SAAS,EAAE,EAAE;IAC5C,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AAEI,KAAK,UAAU,SAAS,CAAC,MAAW;IACzC,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3C,MAAM,EAAE,IAAI,qBAAY,EAAE;QAC1B,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE;QACrB,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IACH,GAAG,CAAC,cAAc,CAAC,IAAI,uBAAc,EAAE,CAAC,CAAC;IACzC,GAAG,CAAC,gBAAgB,CAAC,IAAI,wCAAqB,EAAE,CAAC,CAAC;IAClD,GAAG,CAAC,UAAU,EAAE,CAAC;IAEjB,MAAM,MAAM,GAAG,IAAI,yBAAe,EAAE;SACjC,QAAQ,CAAC,MAAM,CAAC;SAChB,SAAS,CAAC,WAAW,EAAE,sBAAsB,CAAC;SAC9C,aAAa,EAAE;SACf,KAAK,EAAE,CAAC;IAEX,MAAM,QAAQ,GAAG,uBAAa,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC3D,uBAAa,CAAC,KAAK,CAAC,KAAK,EAAE,GAAU,EAAE,QAAQ,CAAC,CAAC;IAEjD,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACjC,IAAA,kBAAa,EAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxD,IAAA,cAAI,EAAC,CAAC,CAAC,CAAC;IACV,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonAppModule = void 0;
|
|
4
|
+
const json_body_middleware_1 = require("../middlewares/json-body.middleware");
|
|
5
|
+
const request_logging_middleware_1 = require("../middlewares/request-logging.middleware");
|
|
6
|
+
class CommonAppModule {
|
|
7
|
+
configure(consumer) {
|
|
8
|
+
consumer.apply(request_logging_middleware_1.RequestLoggingMiddleware, json_body_middleware_1.JsonBodyMiddleware).forRoutes('*');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.CommonAppModule = CommonAppModule;
|
|
12
|
+
//# sourceMappingURL=common-app.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-app.module.js","sourceRoot":"","sources":["../../src/executables/common-app.module.ts"],"names":[],"mappings":";;;AACA,8EAAyE;AACzE,0FAAqF;AAErF,MAAsB,eAAe;IAC5B,SAAS,CAAC,QAA4B;QAC3C,QAAQ,CAAC,KAAK,CAAC,qDAAwB,EAAE,yCAAkB,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9E,CAAC;CACF;AAJD,0CAIC"}
|
|
@@ -6,9 +6,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.CommonExceptionFilter = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
|
-
let
|
|
11
|
+
let CommonExceptionFilter = class CommonExceptionFilter {
|
|
12
12
|
catch(error, host) {
|
|
13
13
|
const ctx = host.switchToHttp();
|
|
14
14
|
const response = ctx.getResponse();
|
|
@@ -23,8 +23,8 @@ let ErrorFilter = class ErrorFilter {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
26
|
+
exports.CommonExceptionFilter = CommonExceptionFilter;
|
|
27
|
+
exports.CommonExceptionFilter = CommonExceptionFilter = __decorate([
|
|
28
28
|
(0, common_1.Catch)(Error)
|
|
29
|
-
],
|
|
29
|
+
], CommonExceptionFilter);
|
|
30
30
|
//# sourceMappingURL=exception-filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception-filter.js","sourceRoot":"","sources":["../../src/helpers/exception-filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkG;AAI3F,IAAM,
|
|
1
|
+
{"version":3,"file":"exception-filter.js","sourceRoot":"","sources":["../../src/helpers/exception-filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkG;AAI3F,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACzB,KAAK,CAAC,KAAY,EAAE,IAAmB;QAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAE7C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAErB,IAAI,KAAK,YAAY,sBAAa,EAAE,CAAC;YACnC,MAAM,aAAa,GAAG,KAAsB,CAAC;YAC7C,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;YAC7E,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,MAAM,CAAC,mBAAU,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC;YACrD,IAAI,EAAE,cAAc;SACrB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,cAAK,EAAC,KAAK,CAAC;GACA,qBAAqB,CAiBjC"}
|
package/helpers/logger.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoggerService } from '@nestjs/common';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class CommonLogger implements LoggerService {
|
|
3
3
|
private formatString;
|
|
4
4
|
private logToConsole;
|
|
5
5
|
log(message: any, ...optionalParams: any): void;
|
package/helpers/logger.js
CHANGED
|
@@ -6,9 +6,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.CommonLogger = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
|
-
let
|
|
11
|
+
let CommonLogger = class CommonLogger {
|
|
12
12
|
formatString(message, ...optionalParams) {
|
|
13
13
|
return message.replace(/{([0-9]+)}/g, (match, index) => (typeof optionalParams[index] === 'undefined' ? match : optionalParams[index]));
|
|
14
14
|
}
|
|
@@ -32,8 +32,8 @@ let CustomerLogger = class CustomerLogger {
|
|
|
32
32
|
this.logToConsole('VERBOSE', message, optionalParams);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
exports.
|
|
36
|
-
exports.
|
|
35
|
+
exports.CommonLogger = CommonLogger;
|
|
36
|
+
exports.CommonLogger = CommonLogger = __decorate([
|
|
37
37
|
(0, common_1.Injectable)()
|
|
38
|
-
],
|
|
38
|
+
], CommonLogger);
|
|
39
39
|
//# sourceMappingURL=logger.js.map
|
package/helpers/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/helpers/logger.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2D;AAGpD,IAAM,
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/helpers/logger.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2D;AAGpD,IAAM,YAAY,GAAlB,MAAM,YAAY;IACf,YAAY,CAAC,OAAe,EAAE,GAAG,cAAqB;QAC5D,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,cAAc,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1I,CAAC;IAEO,YAAY,CAAC,KAAa,EAAE,OAAY,EAAE,GAAG,cAAmB;QACtE,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAE1C,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,KAAK,MAAM,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;IACtI,CAAC;IAEM,GAAG,CAAC,OAAY,EAAE,GAAG,cAAmB;QAC7C,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC;IAEM,KAAK,CAAC,OAAY,EAAE,GAAG,cAAmB;QAC/C,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC;IAEM,IAAI,CAAC,OAAY,EAAE,GAAG,cAAmB;QAC9C,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC;IAEM,KAAK,CAAE,OAAY,EAAE,GAAG,cAAmB;QAChD,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC;IAEM,OAAO,CAAE,OAAY,EAAE,GAAG,cAAmB;QAClD,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AA9BY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;GACA,YAAY,CA8BxB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.JsonBodyMiddleware = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const bodyParser = require("body-parser");
|
|
12
|
+
let JsonBodyMiddleware = class JsonBodyMiddleware {
|
|
13
|
+
use(req, res, next) {
|
|
14
|
+
bodyParser.json()(req, res, next);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.JsonBodyMiddleware = JsonBodyMiddleware;
|
|
18
|
+
exports.JsonBodyMiddleware = JsonBodyMiddleware = __decorate([
|
|
19
|
+
(0, common_1.Injectable)()
|
|
20
|
+
], JsonBodyMiddleware);
|
|
21
|
+
//# sourceMappingURL=json-body.middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-body.middleware.js","sourceRoot":"","sources":["../../src/middlewares/json-body.middleware.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4D;AAC5D,0CAA0C;AAInC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACvB,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAe;QACtD,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;CACD,CAAA;AAJY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAI9B"}
|