@nest-omni/core 3.1.1-10 → 3.1.1-9
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/package.json +27 -19
- package/.hygen/new/crud/controller.ejs.t +0 -82
- package/.hygen/new/crud/create.dto.ejs.t +0 -12
- package/.hygen/new/crud/entity.ejs.t +0 -26
- package/.hygen/new/crud/get.dto.ejs.t +0 -19
- package/.hygen/new/crud/index-dto.ejs.t +0 -29
- package/.hygen/new/crud/index-response.dto.ejs.t +0 -18
- package/.hygen/new/crud/module.ejs.t +0 -32
- package/.hygen/new/crud/prompt.js +0 -89
- package/.hygen/new/crud/service.ejs.t +0 -76
- package/.hygen/new/crud/update.dto.ejs.t +0 -11
- package/.hygen/new/module/controller.ejs.t +0 -93
- package/.hygen/new/module/create-command.ejs.t +0 -90
- package/.hygen/new/module/create.dto.ejs.t +0 -11
- package/.hygen/new/module/dto.ejs.t +0 -24
- package/.hygen/new/module/entity.ejs.t +0 -33
- package/.hygen/new/module/get-query.ejs.t +0 -57
- package/.hygen/new/module/module.ejs.t +0 -44
- package/.hygen/new/module/not-found.exception.ejs.t +0 -18
- package/.hygen/new/module/page-options.dto.ejs.t +0 -12
- package/.hygen/new/module/prompt.js +0 -104
- package/.hygen/new/module/repository.ejs.t +0 -16
- package/.hygen/new/module/service.ejs.t +0 -139
- package/.hygen/new/module/translation-dto.ejs.t +0 -27
- package/.hygen/new/module/translation-entity.ejs.t +0 -40
- package/.hygen/new/module/translation-repository.ejs.t +0 -16
- package/.hygen/new/module/update.dto.ejs.t +0 -10
- package/.hygen.js +0 -116
- package/common/abstract.entity.d.ts +0 -18
- package/common/abstract.entity.js +0 -78
- package/common/boilerplate.polyfill.d.ts +0 -39
- package/common/boilerplate.polyfill.js +0 -77
- package/common/dto/abstract.dto.d.ts +0 -13
- package/common/dto/abstract.dto.js +0 -59
- package/common/dto/bulk-id.dto.d.ts +0 -3
- package/common/dto/bulk-id.dto.js +0 -27
- package/common/dto/create-translation.dto.d.ts +0 -5
- package/common/dto/create-translation.dto.js +0 -25
- package/common/dto/index.d.ts +0 -6
- package/common/dto/index.js +0 -22
- package/common/dto/page-meta.dto.d.ts +0 -15
- package/common/dto/page-meta.dto.js +0 -48
- package/common/dto/page-options.dto.d.ts +0 -8
- package/common/dto/page-options.dto.js +0 -52
- package/common/dto/page.dto.d.ts +0 -11
- package/common/dto/page.dto.js +0 -53
- package/common/index.d.ts +0 -6
- package/common/index.js +0 -22
- package/common/snake-naming.strategy.d.ts +0 -11
- package/common/snake-naming.strategy.js +0 -37
- package/common/types.d.ts +0 -9
- package/common/types.js +0 -2
- package/common/utils.d.ts +0 -3
- package/common/utils.js +0 -24
- package/constants/index.d.ts +0 -2
- package/constants/index.js +0 -18
- package/constants/language-code.d.ts +0 -5
- package/constants/language-code.js +0 -9
- package/constants/order.d.ts +0 -4
- package/constants/order.js +0 -8
- package/decorators/api-page-ok-response.decorator.d.ts +0 -5
- package/decorators/api-page-ok-response.decorator.js +0 -24
- package/decorators/auth-user.decorator.d.ts +0 -1
- package/decorators/auth-user.decorator.js +0 -14
- package/decorators/controller.decorator.d.ts +0 -1
- package/decorators/controller.decorator.js +0 -10
- package/decorators/field.decorators.d.ts +0 -79
- package/decorators/field.decorators.js +0 -497
- package/decorators/http.decorators.d.ts +0 -3
- package/decorators/http.decorators.js +0 -7
- package/decorators/index.d.ts +0 -12
- package/decorators/index.js +0 -28
- package/decorators/operation.decorator.d.ts +0 -1
- package/decorators/operation.decorator.js +0 -6
- package/decorators/property.decorators.d.ts +0 -15
- package/decorators/property.decorators.js +0 -31
- package/decorators/public-route.decorator.d.ts +0 -3
- package/decorators/public-route.decorator.js +0 -7
- package/decorators/swagger.schema.d.ts +0 -5
- package/decorators/swagger.schema.js +0 -78
- package/decorators/timestamp-column.decorator.d.ts +0 -1
- package/decorators/timestamp-column.decorator.js +0 -27
- package/decorators/transform.decorators.d.ts +0 -8
- package/decorators/transform.decorators.js +0 -100
- package/decorators/translate.decorator.d.ts +0 -5
- package/decorators/translate.decorator.js +0 -17
- package/decorators/use-dto.decorator.d.ts +0 -4
- package/decorators/use-dto.decorator.js +0 -8
- package/decorators/user-check.decorator.d.ts +0 -6
- package/decorators/user-check.decorator.js +0 -21
- package/decorators/user.decorator.d.ts +0 -12
- package/decorators/user.decorator.js +0 -44
- package/decorators/user_auth.decorator.d.ts +0 -1
- package/decorators/user_auth.decorator.js +0 -15
- package/decorators/validator.decorators.d.ts +0 -11
- package/decorators/validator.decorators.js +0 -78
- package/exceptions/file-not-image.exception.d.ts +0 -4
- package/exceptions/file-not-image.exception.js +0 -10
- package/exceptions/index.d.ts +0 -2
- package/exceptions/index.js +0 -18
- package/exceptions/page-type.exception.d.ts +0 -4
- package/exceptions/page-type.exception.js +0 -10
- package/exceptions/user-not-found.exception.d.ts +0 -4
- package/exceptions/user-not-found.exception.js +0 -10
- package/filters/bad-request.filter.d.ts +0 -5
- package/filters/bad-request.filter.js +0 -71
- package/filters/constraint-errors.d.ts +0 -1
- package/filters/constraint-errors.js +0 -6
- package/filters/index.d.ts +0 -3
- package/filters/index.js +0 -19
- package/filters/query-failed.filter.d.ts +0 -10
- package/filters/query-failed.filter.js +0 -42
- package/health-checker/health-checker.controller.d.ts +0 -13
- package/health-checker/health-checker.controller.js +0 -69
- package/health-checker/health-checker.module.d.ts +0 -2
- package/health-checker/health-checker.module.js +0 -24
- package/health-checker/index.d.ts +0 -2
- package/health-checker/index.js +0 -18
- package/helpers/common.helper.d.ts +0 -3
- package/helpers/common.helper.js +0 -36
- package/helpers/date.helper.d.ts +0 -10
- package/helpers/date.helper.js +0 -57
- package/helpers/index.d.ts +0 -2
- package/helpers/index.js +0 -18
- package/i18n/en_US/validation.json +0 -41
- package/i18n/zh_CN/validation.json +0 -41
- package/index.d.ts +0 -15
- package/interceptors/index.d.ts +0 -2
- package/interceptors/index.js +0 -18
- package/interceptors/language-interceptor.service.d.ts +0 -6
- package/interceptors/language-interceptor.service.js +0 -29
- package/interceptors/translation-interceptor.service.d.ts +0 -5
- package/interceptors/translation-interceptor.service.js +0 -34
- package/interfaces/IApiFile.d.ts +0 -4
- package/interfaces/IApiFile.js +0 -2
- package/interfaces/IFile.d.ts +0 -8
- package/interfaces/IFile.js +0 -2
- package/interfaces/ITranslationDecoratorInterface.d.ts +0 -3
- package/interfaces/ITranslationDecoratorInterface.js +0 -2
- package/interfaces/index.d.ts +0 -3
- package/interfaces/index.js +0 -19
- package/interfaces/response.d.ts +0 -25
- package/interfaces/response.js +0 -2
- package/middlewares/index.d.ts +0 -4
- package/middlewares/index.js +0 -20
- package/middlewares/omni-auth.middleware.d.ts +0 -1
- package/middlewares/omni-auth.middleware.js +0 -13
- package/middlewares/powerby.middleware.d.ts +0 -1
- package/middlewares/powerby.middleware.js +0 -10
- package/middlewares/request-id.middleware.d.ts +0 -7
- package/middlewares/request-id.middleware.js +0 -22
- package/middlewares/xml.middleware.d.ts +0 -4
- package/middlewares/xml.middleware.js +0 -24
- package/providers/context.provider.d.ts +0 -34
- package/providers/context.provider.js +0 -80
- package/providers/generator.provider.d.ts +0 -9
- package/providers/generator.provider.js +0 -50
- package/providers/index.d.ts +0 -2
- package/providers/index.js +0 -18
- package/setup/bootstrap.setup.d.ts +0 -2
- package/setup/bootstrap.setup.js +0 -177
- package/setup/index.d.ts +0 -6
- package/setup/index.js +0 -22
- package/setup/mode.setup.d.ts +0 -12
- package/setup/mode.setup.js +0 -60
- package/setup/redis.lock.decorator.d.ts +0 -5
- package/setup/redis.lock.decorator.js +0 -60
- package/setup/redis.lock.service.d.ts +0 -56
- package/setup/redis.lock.service.js +0 -338
- package/setup/schedule.decorator.d.ts +0 -21
- package/setup/schedule.decorator.js +0 -127
- package/setup/worker.decorator.d.ts +0 -14
- package/setup/worker.decorator.js +0 -130
- package/shared/index.d.ts +0 -2
- package/shared/index.js +0 -18
- package/shared/serviceRegistryModule.d.ts +0 -2
- package/shared/serviceRegistryModule.js +0 -109
- package/shared/services/api-config.service.d.ts +0 -59
- package/shared/services/api-config.service.js +0 -311
- package/shared/services/generator.service.d.ts +0 -4
- package/shared/services/generator.service.js +0 -23
- package/shared/services/index.d.ts +0 -4
- package/shared/services/index.js +0 -20
- package/shared/services/translation.service.d.ts +0 -9
- package/shared/services/translation.service.js +0 -70
- package/shared/services/validator.service.d.ts +0 -3
- package/shared/services/validator.service.js +0 -20
- package/validator-json/decorators.d.ts +0 -6
- package/validator-json/decorators.js +0 -22
- package/validator-json/default.d.ts +0 -6
- package/validator-json/default.js +0 -138
- package/validator-json/defaultConverters.d.ts +0 -8
- package/validator-json/defaultConverters.js +0 -376
- package/validator-json/index.d.ts +0 -4
- package/validator-json/index.js +0 -20
- package/validator-json/options.d.ts +0 -11
- package/validator-json/options.js +0 -10
- package/validators/file-mimetype.validator.d.ts +0 -13
- package/validators/file-mimetype.validator.js +0 -21
- package/validators/index.d.ts +0 -6
- package/validators/index.js +0 -22
- package/validators/is-exists.validator.d.ts +0 -18
- package/validators/is-exists.validator.js +0 -60
- package/validators/is-unique.validator.d.ts +0 -17
- package/validators/is-unique.validator.js +0 -91
- package/validators/phone-country-code.validator.d.ts +0 -2
- package/validators/phone-country-code.validator.js +0 -29
- package/validators/same-as.validator.d.ts +0 -2
- package/validators/same-as.validator.js +0 -24
- package/validators/skip-empty.validator.d.ts +0 -1
- package/validators/skip-empty.validator.js +0 -17
package/middlewares/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./request-id.middleware"), exports);
|
|
18
|
-
__exportStar(require("./powerby.middleware"), exports);
|
|
19
|
-
__exportStar(require("./omni-auth.middleware"), exports);
|
|
20
|
-
__exportStar(require("./xml.middleware"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const OmniAuthMiddleware: () => (req: any, res: any, next: any) => void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OmniAuthMiddleware = void 0;
|
|
4
|
-
const user_decorator_1 = require("../decorators/user.decorator");
|
|
5
|
-
const providers_1 = require("../providers");
|
|
6
|
-
const OmniAuthMiddleware = () => {
|
|
7
|
-
return (req, res, next) => {
|
|
8
|
-
req.user = (0, user_decorator_1.getOmniAuthData)(req);
|
|
9
|
-
providers_1.ContextProvider.setAuthUser(req.user);
|
|
10
|
-
next();
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
exports.OmniAuthMiddleware = OmniAuthMiddleware;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const PowerByMiddleware: (by?: string) => (req: any, res: any, next: any) => void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PowerByMiddleware = void 0;
|
|
4
|
-
const PowerByMiddleware = (by = 'KN') => {
|
|
5
|
-
return (req, res, next) => {
|
|
6
|
-
res.header('x-powered-by', by);
|
|
7
|
-
next();
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
exports.PowerByMiddleware = PowerByMiddleware;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
export interface RequestIdConfig {
|
|
3
|
-
header: string;
|
|
4
|
-
idGenerator: () => string;
|
|
5
|
-
setHeader: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare const RequestIdMiddleware: (config?: RequestIdConfig) => (req: Request, res: Response, next: NextFunction) => void;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RequestIdMiddleware = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
const providers_1 = require("../providers");
|
|
6
|
-
const RequestIdMiddleware = (config = {
|
|
7
|
-
header: 'x-request-id',
|
|
8
|
-
idGenerator: uuid_1.v4,
|
|
9
|
-
setHeader: true,
|
|
10
|
-
}) => {
|
|
11
|
-
return (req, res, next) => {
|
|
12
|
-
const requestId = req.header(config.header) || config.idGenerator();
|
|
13
|
-
req.headers[config.header] = requestId;
|
|
14
|
-
req.id = requestId;
|
|
15
|
-
providers_1.ContextProvider.setRequestId(requestId);
|
|
16
|
-
if (config.setHeader) {
|
|
17
|
-
res.set(config.header, requestId);
|
|
18
|
-
}
|
|
19
|
-
next();
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.RequestIdMiddleware = RequestIdMiddleware;
|
|
@@ -1,24 +0,0 @@
|
|
|
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.XMLMiddleware = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const bodyParser = require("body-parser");
|
|
12
|
-
const bodyParserMiddleware = bodyParser.text({
|
|
13
|
-
limit: '1024kb',
|
|
14
|
-
type: 'application/xml',
|
|
15
|
-
});
|
|
16
|
-
let XMLMiddleware = class XMLMiddleware {
|
|
17
|
-
use(req, res, next) {
|
|
18
|
-
bodyParserMiddleware(req, res, next);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
exports.XMLMiddleware = XMLMiddleware;
|
|
22
|
-
exports.XMLMiddleware = XMLMiddleware = __decorate([
|
|
23
|
-
(0, common_1.Injectable)()
|
|
24
|
-
], XMLMiddleware);
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { IUser } from '../decorators/user.decorator';
|
|
2
|
-
export declare class ContextProvider {
|
|
3
|
-
private static readonly nameSpace;
|
|
4
|
-
private static readonly authUserKey;
|
|
5
|
-
private static readonly routerKey;
|
|
6
|
-
private static readonly languageKey;
|
|
7
|
-
private static readonly requestKey;
|
|
8
|
-
static get<T>(key: string): import("nestjs-cls/dist/src/types/type-if-type.type").TypeIfUndefined<T, import("nestjs-cls").ClsStore, T>;
|
|
9
|
-
static set(key: string, value: any): void;
|
|
10
|
-
static getKeyWithNamespace(key: string): string;
|
|
11
|
-
static setRouter(user: any): void;
|
|
12
|
-
static getCanLog(): boolean;
|
|
13
|
-
static getRouter(): {
|
|
14
|
-
action: {
|
|
15
|
-
feature: string;
|
|
16
|
-
action: string;
|
|
17
|
-
};
|
|
18
|
-
id: string;
|
|
19
|
-
method: object;
|
|
20
|
-
ip: string;
|
|
21
|
-
canLog: boolean;
|
|
22
|
-
};
|
|
23
|
-
static setRequestId(id: string): void;
|
|
24
|
-
static getRequestId(): string;
|
|
25
|
-
static setAuthUser(user: IUser): void;
|
|
26
|
-
static setLanguage(language: string): void;
|
|
27
|
-
static getLanguage(): string;
|
|
28
|
-
static getAuthUserField<T extends keyof IUser>(field?: T): IUser[T];
|
|
29
|
-
static getAuthUser(): IUser;
|
|
30
|
-
static getAppId(): string;
|
|
31
|
-
static getRole(): string;
|
|
32
|
-
static getAdmin(): boolean;
|
|
33
|
-
static getTenantId(): string;
|
|
34
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContextProvider = void 0;
|
|
4
|
-
const nestjs_cls_1 = require("nestjs-cls");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
class ContextProvider {
|
|
7
|
-
static get(key) {
|
|
8
|
-
const store = nestjs_cls_1.ClsServiceManager.getClsService();
|
|
9
|
-
return store.get(ContextProvider.getKeyWithNamespace(key));
|
|
10
|
-
}
|
|
11
|
-
static set(key, value) {
|
|
12
|
-
const store = nestjs_cls_1.ClsServiceManager.getClsService();
|
|
13
|
-
store.set(ContextProvider.getKeyWithNamespace(key), value);
|
|
14
|
-
}
|
|
15
|
-
static getKeyWithNamespace(key) {
|
|
16
|
-
return `${ContextProvider.nameSpace}.${key}`;
|
|
17
|
-
}
|
|
18
|
-
static setRouter(user) {
|
|
19
|
-
ContextProvider.set(ContextProvider.routerKey, user);
|
|
20
|
-
}
|
|
21
|
-
static getCanLog() {
|
|
22
|
-
return ContextProvider.getRouter().canLog;
|
|
23
|
-
}
|
|
24
|
-
static getRouter() {
|
|
25
|
-
const value = ContextProvider.get(ContextProvider.routerKey);
|
|
26
|
-
if (value) {
|
|
27
|
-
return value;
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
action: { feature: '', action: '' },
|
|
31
|
-
id: '',
|
|
32
|
-
method: {},
|
|
33
|
-
ip: '',
|
|
34
|
-
canLog: false,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
static setRequestId(id) {
|
|
38
|
-
ContextProvider.set(ContextProvider.requestKey, id);
|
|
39
|
-
}
|
|
40
|
-
static getRequestId() {
|
|
41
|
-
return ContextProvider.get(ContextProvider.requestKey);
|
|
42
|
-
}
|
|
43
|
-
static setAuthUser(user) {
|
|
44
|
-
ContextProvider.set(ContextProvider.authUserKey, user);
|
|
45
|
-
}
|
|
46
|
-
static setLanguage(language) {
|
|
47
|
-
ContextProvider.set(ContextProvider.languageKey, language);
|
|
48
|
-
}
|
|
49
|
-
static getLanguage() {
|
|
50
|
-
return ContextProvider.get(ContextProvider.languageKey);
|
|
51
|
-
}
|
|
52
|
-
static getAuthUserField(field) {
|
|
53
|
-
return ContextProvider.getAuthUser()[field];
|
|
54
|
-
}
|
|
55
|
-
static getAuthUser() {
|
|
56
|
-
const auth = ContextProvider.get(ContextProvider.authUserKey);
|
|
57
|
-
if (!auth) {
|
|
58
|
-
throw new common_1.BadGatewayException('User information not found.');
|
|
59
|
-
}
|
|
60
|
-
return auth;
|
|
61
|
-
}
|
|
62
|
-
static getAppId() {
|
|
63
|
-
return ContextProvider.getAuthUserField('appId');
|
|
64
|
-
}
|
|
65
|
-
static getRole() {
|
|
66
|
-
return ContextProvider.getAuthUserField('role');
|
|
67
|
-
}
|
|
68
|
-
static getAdmin() {
|
|
69
|
-
return ContextProvider.getAuthUserField('admin');
|
|
70
|
-
}
|
|
71
|
-
static getTenantId() {
|
|
72
|
-
return ContextProvider.getAuthUserField('tenantId');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.ContextProvider = ContextProvider;
|
|
76
|
-
ContextProvider.nameSpace = 'request';
|
|
77
|
-
ContextProvider.authUserKey = 'user_key';
|
|
78
|
-
ContextProvider.routerKey = 'router_key';
|
|
79
|
-
ContextProvider.languageKey = 'language_key';
|
|
80
|
-
ContextProvider.requestKey = 'request_key';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class GeneratorProvider {
|
|
2
|
-
static uuid(): string;
|
|
3
|
-
static fileName(ext: string): string;
|
|
4
|
-
static getS3PublicUrl(key: string): string;
|
|
5
|
-
static getS3Key(publicUrl: string): string;
|
|
6
|
-
static generateVerificationCode(): string;
|
|
7
|
-
static generatePassword(): string;
|
|
8
|
-
static generateRandomString(length: number): string;
|
|
9
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GeneratorProvider = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
class GeneratorProvider {
|
|
6
|
-
static uuid() {
|
|
7
|
-
return (0, uuid_1.v1)();
|
|
8
|
-
}
|
|
9
|
-
static fileName(ext) {
|
|
10
|
-
return GeneratorProvider.uuid() + '.' + ext;
|
|
11
|
-
}
|
|
12
|
-
static getS3PublicUrl(key) {
|
|
13
|
-
if (!key) {
|
|
14
|
-
throw new TypeError('key is required');
|
|
15
|
-
}
|
|
16
|
-
return `https://s3.${process.env.AWS_S3_BUCKET_NAME_REGION}.amazonaws.com/${process.env.AWS_S3_BUCKET_NAME}/${key}`;
|
|
17
|
-
}
|
|
18
|
-
static getS3Key(publicUrl) {
|
|
19
|
-
if (!publicUrl) {
|
|
20
|
-
throw new TypeError('key is required');
|
|
21
|
-
}
|
|
22
|
-
const exec = new RegExp(`(?<=https://s3.${process.env.AWS_S3_BUCKET_NAME_REGION}.amazonaws.com/${process.env.AWS_S3_BUCKET_NAME}/).*`).exec(publicUrl);
|
|
23
|
-
if (!exec) {
|
|
24
|
-
throw new TypeError('publicUrl is invalid');
|
|
25
|
-
}
|
|
26
|
-
return exec[0];
|
|
27
|
-
}
|
|
28
|
-
static generateVerificationCode() {
|
|
29
|
-
return Math.floor(1000 + Math.random() * 9000).toString();
|
|
30
|
-
}
|
|
31
|
-
static generatePassword() {
|
|
32
|
-
const lowercase = 'abcdefghijklmnopqrstuvwxyz';
|
|
33
|
-
const uppercase = lowercase.toUpperCase();
|
|
34
|
-
const numbers = '0123456789';
|
|
35
|
-
let text = '';
|
|
36
|
-
for (let i = 0; i < 12; i++) {
|
|
37
|
-
text += uppercase.charAt(Math.floor(Math.random() * uppercase.length));
|
|
38
|
-
text += lowercase.charAt(Math.floor(Math.random() * lowercase.length));
|
|
39
|
-
text += numbers.charAt(Math.floor(Math.random() * numbers.length));
|
|
40
|
-
}
|
|
41
|
-
return text;
|
|
42
|
-
}
|
|
43
|
-
static generateRandomString(length) {
|
|
44
|
-
return Math.random()
|
|
45
|
-
.toString(36)
|
|
46
|
-
.replace(/[^\dA-Za-z]+/g, '')
|
|
47
|
-
.slice(0, Math.max(0, length));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.GeneratorProvider = GeneratorProvider;
|
package/providers/index.d.ts
DELETED
package/providers/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./context.provider"), exports);
|
|
18
|
-
__exportStar(require("./generator.provider"), exports);
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import type { NestExpressApplication } from '@nestjs/platform-express';
|
|
2
|
-
export declare function bootstrapSetup(AppModule: any, SetupSwagger: any): Promise<NestExpressApplication<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>>>;
|
package/setup/bootstrap.setup.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.bootstrapSetup = bootstrapSetup;
|
|
13
|
-
const Sentry = require("@sentry/nestjs");
|
|
14
|
-
const profiling_node_1 = require("@sentry/profiling-node");
|
|
15
|
-
const dotenv = require("dotenv");
|
|
16
|
-
const fs_1 = require("fs");
|
|
17
|
-
const path_1 = require("path");
|
|
18
|
-
const process = require("process");
|
|
19
|
-
const mode_setup_1 = require("./mode.setup");
|
|
20
|
-
function findValidRootPath() {
|
|
21
|
-
const getAppRootPath = () => {
|
|
22
|
-
if (require.main && require.main.filename) {
|
|
23
|
-
return (0, path_1.dirname)(require.main.filename);
|
|
24
|
-
}
|
|
25
|
-
if (process.argv[1]) {
|
|
26
|
-
return (0, path_1.dirname)(process.argv[1]);
|
|
27
|
-
}
|
|
28
|
-
return process.cwd();
|
|
29
|
-
};
|
|
30
|
-
const possibleRootPaths = [getAppRootPath(), process.cwd(), __dirname];
|
|
31
|
-
const envFile = `${process.env.NODE_ENV || ''}.env`;
|
|
32
|
-
const isTest = process.env.NODE_ENV === 'test';
|
|
33
|
-
let envFilePath = '';
|
|
34
|
-
for (const rootPath of possibleRootPaths) {
|
|
35
|
-
const configPath = (0, path_1.join)(rootPath, 'config');
|
|
36
|
-
const baseEnvFilePath = (0, path_1.join)(configPath, 'base.env');
|
|
37
|
-
if (isTest) {
|
|
38
|
-
envFilePath = (0, path_1.join)(configPath, 'test.env');
|
|
39
|
-
if ((0, fs_1.existsSync)(envFilePath)) {
|
|
40
|
-
return { rootPath, baseEnvFilePath, envFilePath };
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
envFilePath = (0, path_1.join)(configPath, 'dev.env');
|
|
44
|
-
if ((0, fs_1.existsSync)(envFilePath)) {
|
|
45
|
-
return { rootPath, baseEnvFilePath, envFilePath };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
envFilePath = (0, path_1.join)(configPath, envFile);
|
|
51
|
-
if ((0, fs_1.existsSync)(envFilePath)) {
|
|
52
|
-
return { rootPath, baseEnvFilePath, envFilePath };
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
throw new Error(`No valid .env file: ${envFilePath}`);
|
|
57
|
-
}
|
|
58
|
-
const { envFilePath, rootPath, baseEnvFilePath } = findValidRootPath();
|
|
59
|
-
dotenv.config({ path: [envFilePath, baseEnvFilePath] });
|
|
60
|
-
process.env.ROOT_PATH = rootPath;
|
|
61
|
-
process.env.ENV_FILE_PATH = envFilePath;
|
|
62
|
-
process.env.BASE_ENV_FILE_PATH = baseEnvFilePath;
|
|
63
|
-
const requiredEnvVars = ['SENTRY_DSN', 'API_VERSION', 'NODE_ENV'];
|
|
64
|
-
requiredEnvVars.forEach((envVar) => {
|
|
65
|
-
if (!process.env[envVar]) {
|
|
66
|
-
throw new Error(`Missing required environment variable: ${envVar}`);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
Sentry.init({
|
|
70
|
-
dsn: process.env.SENTRY_DSN || '',
|
|
71
|
-
release: process.env.API_VERSION || '',
|
|
72
|
-
environment: process.env.NODE_ENV || 'unkown',
|
|
73
|
-
debug: false,
|
|
74
|
-
sampleRate: 1.0,
|
|
75
|
-
tracesSampleRate: 0.01,
|
|
76
|
-
profileSessionSampleRate: 0.01,
|
|
77
|
-
profileLifecycle: 'trace',
|
|
78
|
-
sendDefaultPii: true,
|
|
79
|
-
integrations: [profiling_node_1.nodeProfilingIntegration],
|
|
80
|
-
});
|
|
81
|
-
const crud_1 = require("@dataui/crud");
|
|
82
|
-
const core_1 = require("@nestjs/core");
|
|
83
|
-
const nestjs_pino_1 = require("nestjs-pino");
|
|
84
|
-
const session = require("express-session");
|
|
85
|
-
const bodyParse = require("body-parser");
|
|
86
|
-
const compression = require("compression");
|
|
87
|
-
const __1 = require("../");
|
|
88
|
-
const common_1 = require("@nestjs/common");
|
|
89
|
-
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
90
|
-
const nestjs_cls_1 = require("nestjs-cls");
|
|
91
|
-
const class_validator_1 = require("class-validator");
|
|
92
|
-
const setup_1 = require("@sentry/nestjs/setup");
|
|
93
|
-
crud_1.CrudConfigService.load({
|
|
94
|
-
auth: {
|
|
95
|
-
property: 'user',
|
|
96
|
-
},
|
|
97
|
-
params: {
|
|
98
|
-
id: {
|
|
99
|
-
field: 'id',
|
|
100
|
-
type: 'string',
|
|
101
|
-
primary: true,
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
query: {
|
|
105
|
-
limit: 10,
|
|
106
|
-
alwaysPaginate: true,
|
|
107
|
-
},
|
|
108
|
-
routes: {
|
|
109
|
-
updateOneBase: {
|
|
110
|
-
allowParamsOverride: false,
|
|
111
|
-
},
|
|
112
|
-
deleteOneBase: {
|
|
113
|
-
returnDeleted: false,
|
|
114
|
-
},
|
|
115
|
-
createOneBase: {
|
|
116
|
-
returnShallow: false,
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
function bootstrapSetup(AppModule, SetupSwagger) {
|
|
121
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
const shouldStartHttp = (0, mode_setup_1.shouldStartHttpServer)();
|
|
123
|
-
const app = yield core_1.NestFactory.create(AppModule, {
|
|
124
|
-
bufferLogs: true,
|
|
125
|
-
autoFlushLogs: true,
|
|
126
|
-
});
|
|
127
|
-
(0, class_validator_1.useContainer)(app.select(AppModule), { fallbackOnErrors: true });
|
|
128
|
-
const configService = app.select(__1.ServiceRegistryModule).get(__1.ApiConfigService);
|
|
129
|
-
const logger = app.get(nestjs_pino_1.Logger);
|
|
130
|
-
app.useLogger(logger);
|
|
131
|
-
app.flushLogs();
|
|
132
|
-
logger.log(`Application Mode: ${(0, mode_setup_1.getModeDescription)()}`);
|
|
133
|
-
logger.log(`Environment: ${process.env.NODE_ENV || 'unknown'}`);
|
|
134
|
-
app.enableShutdownHooks();
|
|
135
|
-
app.enableVersioning();
|
|
136
|
-
app.enable('trust proxy');
|
|
137
|
-
app.use(bodyParse.json({ limit: '50mb' }), new nestjs_cls_1.ClsMiddleware({}).use, (0, __1.RequestIdMiddleware)(), (0, __1.PowerByMiddleware)(), (0, __1.OmniAuthMiddleware)(), compression());
|
|
138
|
-
const reflector = app.get(core_1.Reflector);
|
|
139
|
-
app.useGlobalFilters(new setup_1.SentryGlobalFilter(), new __1.HttpExceptionFilter(), new __1.QueryFailedFilter(reflector));
|
|
140
|
-
app.useGlobalInterceptors(new __1.LanguageInterceptor(), new __1.TranslationInterceptor(), new nestjs_pino_1.LoggerErrorInterceptor());
|
|
141
|
-
app.useGlobalPipes(new nestjs_i18n_1.I18nValidationPipe({
|
|
142
|
-
whitelist: true,
|
|
143
|
-
errorHttpStatusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
144
|
-
transform: true,
|
|
145
|
-
stopAtFirstError: true,
|
|
146
|
-
validationError: { target: false, value: false },
|
|
147
|
-
}));
|
|
148
|
-
if (shouldStartHttp) {
|
|
149
|
-
if (configService.documentationEnabled && SetupSwagger) {
|
|
150
|
-
SetupSwagger(app, configService.documentationPath);
|
|
151
|
-
logger.log(`Swagger docs available at ${configService.documentationPath}`);
|
|
152
|
-
}
|
|
153
|
-
if (configService.viewsEnabled) {
|
|
154
|
-
app.setBaseViewsDir((0, path_1.join)(__1.ApiConfigService.rootPath, 'views'));
|
|
155
|
-
app.setViewEngine('ejs');
|
|
156
|
-
logger.log('View engine initialized');
|
|
157
|
-
}
|
|
158
|
-
if (configService.sessionEnabled) {
|
|
159
|
-
app.use(session(configService.sessionConfig));
|
|
160
|
-
logger.log('Session middleware enabled');
|
|
161
|
-
}
|
|
162
|
-
if (configService.corsEnabled) {
|
|
163
|
-
app.enableCors(configService.corsConfig);
|
|
164
|
-
logger.log('CORS configuration applied');
|
|
165
|
-
}
|
|
166
|
-
const port = configService.appConfig.port;
|
|
167
|
-
yield app.listen(port);
|
|
168
|
-
logger.log(`HTTP Server running on ${yield app.getUrl()}`);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
logger.log('Running in Worker-only mode - HTTP server not started');
|
|
172
|
-
logger.log('Application is ready to process background tasks');
|
|
173
|
-
yield app.init();
|
|
174
|
-
}
|
|
175
|
-
return app;
|
|
176
|
-
});
|
|
177
|
-
}
|
package/setup/index.d.ts
DELETED
package/setup/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./bootstrap.setup"), exports);
|
|
18
|
-
__exportStar(require("./mode.setup"), exports);
|
|
19
|
-
__exportStar(require("./worker.decorator"), exports);
|
|
20
|
-
__exportStar(require("./schedule.decorator"), exports);
|
|
21
|
-
__exportStar(require("./redis.lock.service"), exports);
|
|
22
|
-
__exportStar(require("./redis.lock.decorator"), exports);
|
package/setup/mode.setup.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare enum ApplicationMode {
|
|
2
|
-
HTTP = "http",
|
|
3
|
-
WORKER = "worker",
|
|
4
|
-
HYBRID = "hybrid"
|
|
5
|
-
}
|
|
6
|
-
export declare function getApplicationMode(): ApplicationMode;
|
|
7
|
-
export declare function shouldProcessQueues(): boolean;
|
|
8
|
-
export declare function shouldStartHttpServer(): boolean;
|
|
9
|
-
export declare function isHttpMode(): boolean;
|
|
10
|
-
export declare function isWorkerMode(): boolean;
|
|
11
|
-
export declare function isHybridMode(): boolean;
|
|
12
|
-
export declare function getModeDescription(): string;
|
package/setup/mode.setup.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApplicationMode = void 0;
|
|
4
|
-
exports.getApplicationMode = getApplicationMode;
|
|
5
|
-
exports.shouldProcessQueues = shouldProcessQueues;
|
|
6
|
-
exports.shouldStartHttpServer = shouldStartHttpServer;
|
|
7
|
-
exports.isHttpMode = isHttpMode;
|
|
8
|
-
exports.isWorkerMode = isWorkerMode;
|
|
9
|
-
exports.isHybridMode = isHybridMode;
|
|
10
|
-
exports.getModeDescription = getModeDescription;
|
|
11
|
-
var ApplicationMode;
|
|
12
|
-
(function (ApplicationMode) {
|
|
13
|
-
ApplicationMode["HTTP"] = "http";
|
|
14
|
-
ApplicationMode["WORKER"] = "worker";
|
|
15
|
-
ApplicationMode["HYBRID"] = "hybrid";
|
|
16
|
-
})(ApplicationMode || (exports.ApplicationMode = ApplicationMode = {}));
|
|
17
|
-
function getApplicationMode() {
|
|
18
|
-
const mode = (process.env.APP_MODE || process.env.MODE || 'hybrid')
|
|
19
|
-
.toLowerCase()
|
|
20
|
-
.trim();
|
|
21
|
-
switch (mode) {
|
|
22
|
-
case 'http':
|
|
23
|
-
return ApplicationMode.HTTP;
|
|
24
|
-
case 'worker':
|
|
25
|
-
return ApplicationMode.WORKER;
|
|
26
|
-
case 'hybrid':
|
|
27
|
-
default:
|
|
28
|
-
return ApplicationMode.HYBRID;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function shouldProcessQueues() {
|
|
32
|
-
const mode = getApplicationMode();
|
|
33
|
-
return mode === ApplicationMode.WORKER || mode === ApplicationMode.HYBRID;
|
|
34
|
-
}
|
|
35
|
-
function shouldStartHttpServer() {
|
|
36
|
-
const mode = getApplicationMode();
|
|
37
|
-
return mode === ApplicationMode.HTTP || mode === ApplicationMode.HYBRID;
|
|
38
|
-
}
|
|
39
|
-
function isHttpMode() {
|
|
40
|
-
return getApplicationMode() === ApplicationMode.HTTP;
|
|
41
|
-
}
|
|
42
|
-
function isWorkerMode() {
|
|
43
|
-
return getApplicationMode() === ApplicationMode.WORKER;
|
|
44
|
-
}
|
|
45
|
-
function isHybridMode() {
|
|
46
|
-
return getApplicationMode() === ApplicationMode.HYBRID;
|
|
47
|
-
}
|
|
48
|
-
function getModeDescription() {
|
|
49
|
-
const mode = getApplicationMode();
|
|
50
|
-
switch (mode) {
|
|
51
|
-
case ApplicationMode.HTTP:
|
|
52
|
-
return 'HTTP-only mode (no background workers)';
|
|
53
|
-
case ApplicationMode.WORKER:
|
|
54
|
-
return 'Worker-only mode (no HTTP server)';
|
|
55
|
-
case ApplicationMode.HYBRID:
|
|
56
|
-
return 'Hybrid mode (HTTP server + background workers)';
|
|
57
|
-
default:
|
|
58
|
-
return 'Unknown mode';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { LockOptions } from './redis.lock.service';
|
|
2
|
-
export declare function UseRedisLock(lockKey: string, options?: LockOptions & {
|
|
3
|
-
skipReturnValue?: any;
|
|
4
|
-
}): MethodDecorator;
|
|
5
|
-
export declare function UseRedisLockOrSkip(lockKey: string, ttl?: number): MethodDecorator;
|