yingzios-platform-backend-shared 1.0.1
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 +51 -0
- package/dist/apollo/apollo.config.d.ts +26 -0
- package/dist/apollo/apollo.config.d.ts.map +1 -0
- package/dist/apollo/apollo.config.js +2 -0
- package/dist/apollo/apollo.module.d.ts +13 -0
- package/dist/apollo/apollo.module.d.ts.map +1 -0
- package/dist/apollo/apollo.module.js +61 -0
- package/dist/apollo/apollo.service.d.ts +17 -0
- package/dist/apollo/apollo.service.d.ts.map +1 -0
- package/dist/apollo/apollo.service.js +35 -0
- package/dist/apollo/index.d.ts +5 -0
- package/dist/apollo/index.d.ts.map +1 -0
- package/dist/apollo/index.js +17 -0
- package/dist/cache/cache.config.d.ts +28 -0
- package/dist/cache/cache.config.d.ts.map +1 -0
- package/dist/cache/cache.config.js +2 -0
- package/dist/cache/cache.module.d.ts +39 -0
- package/dist/cache/cache.module.d.ts.map +1 -0
- package/dist/cache/cache.module.js +75 -0
- package/dist/cache/cache.service.d.ts +49 -0
- package/dist/cache/cache.service.d.ts.map +1 -0
- package/dist/cache/cache.service.js +208 -0
- package/dist/cache/index.d.ts +4 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +19 -0
- package/dist/env/env-loader.d.ts +50 -0
- package/dist/env/env-loader.d.ts.map +1 -0
- package/dist/env/env-loader.js +159 -0
- package/dist/env/env.module.d.ts +11 -0
- package/dist/env/env.module.d.ts.map +1 -0
- package/dist/env/env.module.js +47 -0
- package/dist/env/env.service.d.ts +31 -0
- package/dist/env/env.service.d.ts.map +1 -0
- package/dist/env/env.service.js +195 -0
- package/dist/env/index.d.ts +4 -0
- package/dist/env/index.d.ts.map +1 -0
- package/dist/env/index.js +19 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/internal-auth/decorators/caller.decorator.d.ts +29 -0
- package/dist/internal-auth/decorators/caller.decorator.d.ts.map +1 -0
- package/dist/internal-auth/decorators/caller.decorator.js +37 -0
- package/dist/internal-auth/decorators/index.d.ts +3 -0
- package/dist/internal-auth/decorators/index.d.ts.map +1 -0
- package/dist/internal-auth/decorators/index.js +18 -0
- package/dist/internal-auth/decorators/use-either-guard.decorator.d.ts +31 -0
- package/dist/internal-auth/decorators/use-either-guard.decorator.d.ts.map +1 -0
- package/dist/internal-auth/decorators/use-either-guard.decorator.js +79 -0
- package/dist/internal-auth/guards/index.d.ts +2 -0
- package/dist/internal-auth/guards/index.d.ts.map +1 -0
- package/dist/internal-auth/guards/index.js +17 -0
- package/dist/internal-auth/guards/service-key.guard.d.ts +36 -0
- package/dist/internal-auth/guards/service-key.guard.d.ts.map +1 -0
- package/dist/internal-auth/guards/service-key.guard.js +86 -0
- package/dist/internal-auth/index.d.ts +43 -0
- package/dist/internal-auth/index.d.ts.map +1 -0
- package/dist/internal-auth/index.js +62 -0
- package/dist/internal-auth/internal-auth.module.d.ts +62 -0
- package/dist/internal-auth/internal-auth.module.d.ts.map +1 -0
- package/dist/internal-auth/internal-auth.module.js +118 -0
- package/dist/internal-auth/internal-http.service.d.ts +72 -0
- package/dist/internal-auth/internal-http.service.d.ts.map +1 -0
- package/dist/internal-auth/internal-http.service.js +119 -0
- package/dist/jwt/auto-fill-user.pipe.d.ts +43 -0
- package/dist/jwt/auto-fill-user.pipe.d.ts.map +1 -0
- package/dist/jwt/auto-fill-user.pipe.js +166 -0
- package/dist/jwt/decorators/current-user.decorator.d.ts +37 -0
- package/dist/jwt/decorators/current-user.decorator.d.ts.map +1 -0
- package/dist/jwt/decorators/current-user.decorator.js +29 -0
- package/dist/jwt/decorators/public.decorator.d.ts +8 -0
- package/dist/jwt/decorators/public.decorator.d.ts.map +1 -0
- package/dist/jwt/decorators/public.decorator.js +12 -0
- package/dist/jwt/guards/jwt-auth.guard.d.ts +20 -0
- package/dist/jwt/guards/jwt-auth.guard.d.ts.map +1 -0
- package/dist/jwt/guards/jwt-auth.guard.js +88 -0
- package/dist/jwt/index.d.ts +8 -0
- package/dist/jwt/index.d.ts.map +1 -0
- package/dist/jwt/index.js +26 -0
- package/dist/jwt/jwt-config.service.d.ts +10 -0
- package/dist/jwt/jwt-config.service.d.ts.map +1 -0
- package/dist/jwt/jwt-config.service.js +40 -0
- package/dist/jwt/jwt.config.d.ts +15 -0
- package/dist/jwt/jwt.config.d.ts.map +1 -0
- package/dist/jwt/jwt.config.js +2 -0
- package/dist/jwt/jwt.module.d.ts +19 -0
- package/dist/jwt/jwt.module.d.ts.map +1 -0
- package/dist/jwt/jwt.module.js +100 -0
- package/dist/jwt/jwt.service.d.ts +31 -0
- package/dist/jwt/jwt.service.d.ts.map +1 -0
- package/dist/jwt/jwt.service.js +71 -0
- package/dist/jwt/strategies/jwt.strategy.d.ts +25 -0
- package/dist/jwt/strategies/jwt.strategy.d.ts.map +1 -0
- package/dist/jwt/strategies/jwt.strategy.js +150 -0
- package/dist/jwt/user-aware-axios.service.d.ts +17 -0
- package/dist/jwt/user-aware-axios.service.d.ts.map +1 -0
- package/dist/jwt/user-aware-axios.service.js +105 -0
- package/dist/jwt/utils/jwt.utils.d.ts +24 -0
- package/dist/jwt/utils/jwt.utils.d.ts.map +1 -0
- package/dist/jwt/utils/jwt.utils.js +40 -0
- package/dist/logger/index.d.ts +4 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +19 -0
- package/dist/logger/logger.config.d.ts +41 -0
- package/dist/logger/logger.config.d.ts.map +1 -0
- package/dist/logger/logger.config.js +13 -0
- package/dist/logger/logger.module.d.ts +17 -0
- package/dist/logger/logger.module.d.ts.map +1 -0
- package/dist/logger/logger.module.js +49 -0
- package/dist/logger/logger.service.d.ts +62 -0
- package/dist/logger/logger.service.d.ts.map +1 -0
- package/dist/logger/logger.service.js +124 -0
- package/dist/logger/winston.config.d.ts +43 -0
- package/dist/logger/winston.config.d.ts.map +1 -0
- package/dist/logger/winston.config.js +183 -0
- package/dist/nacos/index.d.ts +4 -0
- package/dist/nacos/index.d.ts.map +1 -0
- package/dist/nacos/index.js +19 -0
- package/dist/nacos/nacos.config.d.ts +10 -0
- package/dist/nacos/nacos.config.d.ts.map +1 -0
- package/dist/nacos/nacos.config.js +2 -0
- package/dist/nacos/nacos.module.d.ts +9 -0
- package/dist/nacos/nacos.module.d.ts.map +1 -0
- package/dist/nacos/nacos.module.js +42 -0
- package/dist/nacos/nacos.service.d.ts +43 -0
- package/dist/nacos/nacos.service.d.ts.map +1 -0
- package/dist/nacos/nacos.service.js +212 -0
- package/dist/nacos/utils.d.ts +10 -0
- package/dist/nacos/utils.d.ts.map +1 -0
- package/dist/nacos/utils.js +65 -0
- package/dist/restful/current-request.util.d.ts +16 -0
- package/dist/restful/current-request.util.d.ts.map +1 -0
- package/dist/restful/current-request.util.js +34 -0
- package/dist/restful/http-exception.filter.d.ts +24 -0
- package/dist/restful/http-exception.filter.d.ts.map +1 -0
- package/dist/restful/http-exception.filter.js +126 -0
- package/dist/restful/index.d.ts +8 -0
- package/dist/restful/index.d.ts.map +1 -0
- package/dist/restful/index.js +23 -0
- package/dist/restful/request-context.middleware.d.ts +6 -0
- package/dist/restful/request-context.middleware.d.ts.map +1 -0
- package/dist/restful/request-context.middleware.js +25 -0
- package/dist/restful/response-codes.d.ts +104 -0
- package/dist/restful/response-codes.d.ts.map +1 -0
- package/dist/restful/response-codes.js +163 -0
- package/dist/restful/response.dto.d.ts +52 -0
- package/dist/restful/response.dto.d.ts.map +1 -0
- package/dist/restful/response.dto.js +146 -0
- package/dist/restful/response.interceptor.d.ts +17 -0
- package/dist/restful/response.interceptor.d.ts.map +1 -0
- package/dist/restful/response.interceptor.js +86 -0
- package/dist/restful/restful.module.d.ts +5 -0
- package/dist/restful/restful.module.d.ts.map +1 -0
- package/dist/restful/restful.module.js +26 -0
- package/dist/sequelize/index.d.ts +4 -0
- package/dist/sequelize/index.d.ts.map +1 -0
- package/dist/sequelize/index.js +19 -0
- package/dist/sequelize/sequelize.config.d.ts +24 -0
- package/dist/sequelize/sequelize.config.d.ts.map +1 -0
- package/dist/sequelize/sequelize.config.js +5 -0
- package/dist/sequelize/sequelize.module.d.ts +28 -0
- package/dist/sequelize/sequelize.module.d.ts.map +1 -0
- package/dist/sequelize/sequelize.module.js +50 -0
- package/dist/sequelize/sequelize.provider.d.ts +7 -0
- package/dist/sequelize/sequelize.provider.d.ts.map +1 -0
- package/dist/sequelize/sequelize.provider.js +154 -0
- package/dist/snowflake/index.d.ts +4 -0
- package/dist/snowflake/index.d.ts.map +1 -0
- package/dist/snowflake/index.js +19 -0
- package/dist/snowflake/snowflake.config.d.ts +30 -0
- package/dist/snowflake/snowflake.config.d.ts.map +1 -0
- package/dist/snowflake/snowflake.config.js +12 -0
- package/dist/snowflake/snowflake.module.d.ts +17 -0
- package/dist/snowflake/snowflake.module.d.ts.map +1 -0
- package/dist/snowflake/snowflake.module.js +58 -0
- package/dist/snowflake/snowflake.service.d.ts +21 -0
- package/dist/snowflake/snowflake.service.d.ts.map +1 -0
- package/dist/snowflake/snowflake.service.js +44 -0
- package/dist/swagger/index.d.ts +6 -0
- package/dist/swagger/index.d.ts.map +1 -0
- package/dist/swagger/index.js +19 -0
- package/dist/swagger/swagger.config.d.ts +45 -0
- package/dist/swagger/swagger.config.d.ts.map +1 -0
- package/dist/swagger/swagger.config.js +19 -0
- package/dist/swagger/swagger.decorators.d.ts +21 -0
- package/dist/swagger/swagger.decorators.d.ts.map +1 -0
- package/dist/swagger/swagger.decorators.js +112 -0
- package/dist/swagger/swagger.module.d.ts +15 -0
- package/dist/swagger/swagger.module.d.ts.map +1 -0
- package/dist/swagger/swagger.module.js +49 -0
- package/dist/swagger/swagger.service.d.ts +44 -0
- package/dist/swagger/swagger.service.d.ts.map +1 -0
- package/dist/swagger/swagger.service.js +202 -0
- package/package.json +75 -0
|
@@ -0,0 +1,19 @@
|
|
|
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("./sequelize.config"), exports);
|
|
18
|
+
__exportStar(require("./sequelize.provider"), exports);
|
|
19
|
+
__exportStar(require("./sequelize.module"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sequelize 配置接口
|
|
3
|
+
*/
|
|
4
|
+
export interface ISequelizeConfig {
|
|
5
|
+
dialect: 'postgres' | 'mysql' | 'sqlite' | 'mssql';
|
|
6
|
+
host: string;
|
|
7
|
+
port: number;
|
|
8
|
+
username: string;
|
|
9
|
+
password: string;
|
|
10
|
+
database: string;
|
|
11
|
+
schema?: string;
|
|
12
|
+
logging?: boolean | ((sql: string, timing?: number) => void);
|
|
13
|
+
pool?: {
|
|
14
|
+
max?: number;
|
|
15
|
+
min?: number;
|
|
16
|
+
acquire?: number;
|
|
17
|
+
idle?: number;
|
|
18
|
+
};
|
|
19
|
+
/** 是否在启动时自动执行 migration */
|
|
20
|
+
autoMigrate?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare const SEQUELIZE_CONFIG = "SEQUELIZE_CONFIG";
|
|
23
|
+
export declare const SEQUELIZE_INSTANCE = "SEQUELIZE_INSTANCE";
|
|
24
|
+
//# sourceMappingURL=sequelize.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequelize.config.d.ts","sourceRoot":"","sources":["../../src/sequelize/sequelize.config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;IAC7D,IAAI,CAAC,EAAE;QACL,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,2BAA2B;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { ISequelizeConfig } from './sequelize.config';
|
|
3
|
+
export interface SequelizeModuleAsyncOptions {
|
|
4
|
+
useFactory: (...args: any[]) => Promise<ISequelizeConfig> | ISequelizeConfig;
|
|
5
|
+
inject?: any[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Sequelize 模块
|
|
9
|
+
*
|
|
10
|
+
* 使用方式:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* SequelizeModule.forRootAsync({
|
|
13
|
+
* useFactory: (envService: EnvService) => ({
|
|
14
|
+
* dialect: 'postgres',
|
|
15
|
+
* host: envService.getItem('DB_HOST'),
|
|
16
|
+
* port: parseInt(envService.getItem('DB_PORT') || '5432'),
|
|
17
|
+
* username: envService.getItem('DB_USERNAME'),
|
|
18
|
+
* password: envService.getItem('DB_PASSWORD'),
|
|
19
|
+
* database: envService.getItem('DB_DATABASE'),
|
|
20
|
+
* }),
|
|
21
|
+
* inject: [EnvService],
|
|
22
|
+
* })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class SequelizeModule {
|
|
26
|
+
static forRootAsync(options: SequelizeModuleAsyncOptions): DynamicModule;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=sequelize.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequelize.module.d.ts","sourceRoot":"","sources":["../../src/sequelize/sequelize.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAwC,MAAM,oBAAoB,CAAC;AAG5F,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;IAC7E,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAEa,eAAe;IAC1B,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,2BAA2B,GAAG,aAAa;CAazE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
var SequelizeModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SequelizeModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const sequelize_config_1 = require("./sequelize.config");
|
|
13
|
+
const sequelize_provider_1 = require("./sequelize.provider");
|
|
14
|
+
/**
|
|
15
|
+
* Sequelize 模块
|
|
16
|
+
*
|
|
17
|
+
* 使用方式:
|
|
18
|
+
* ```typescript
|
|
19
|
+
* SequelizeModule.forRootAsync({
|
|
20
|
+
* useFactory: (envService: EnvService) => ({
|
|
21
|
+
* dialect: 'postgres',
|
|
22
|
+
* host: envService.getItem('DB_HOST'),
|
|
23
|
+
* port: parseInt(envService.getItem('DB_PORT') || '5432'),
|
|
24
|
+
* username: envService.getItem('DB_USERNAME'),
|
|
25
|
+
* password: envService.getItem('DB_PASSWORD'),
|
|
26
|
+
* database: envService.getItem('DB_DATABASE'),
|
|
27
|
+
* }),
|
|
28
|
+
* inject: [EnvService],
|
|
29
|
+
* })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
let SequelizeModule = SequelizeModule_1 = class SequelizeModule {
|
|
33
|
+
static forRootAsync(options) {
|
|
34
|
+
const configProvider = {
|
|
35
|
+
provide: sequelize_config_1.SEQUELIZE_CONFIG,
|
|
36
|
+
useFactory: options.useFactory,
|
|
37
|
+
inject: options.inject || [],
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
module: SequelizeModule_1,
|
|
41
|
+
providers: [configProvider, sequelize_provider_1.sequelizeProvider],
|
|
42
|
+
exports: [sequelize_config_1.SEQUELIZE_INSTANCE],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.SequelizeModule = SequelizeModule;
|
|
47
|
+
exports.SequelizeModule = SequelizeModule = SequelizeModule_1 = __decorate([
|
|
48
|
+
(0, common_1.Global)(),
|
|
49
|
+
(0, common_1.Module)({})
|
|
50
|
+
], SequelizeModule);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequelize.provider.d.ts","sourceRoot":"","sources":["../../src/sequelize/sequelize.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAqD1C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAgE/B,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.sequelizeProvider = void 0;
|
|
37
|
+
const sequelize_1 = require("sequelize");
|
|
38
|
+
const umzug_1 = require("umzug");
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const sequelize_config_1 = require("./sequelize.config");
|
|
41
|
+
/**
|
|
42
|
+
* 运行数据库迁移
|
|
43
|
+
*
|
|
44
|
+
* 依据:
|
|
45
|
+
* - Umzug 文档:https://github.com/sequelize/umzug
|
|
46
|
+
* - SequelizeStorage 文档:https://github.com/sequelize/umzug/blob/main/src/storage/sequelize.ts
|
|
47
|
+
* - 在多 schema 环境中,SequelizeMeta 表应与业务表放在同一 schema 中
|
|
48
|
+
*/
|
|
49
|
+
async function runMigrations(sequelize, schema = 'public') {
|
|
50
|
+
const migrationsPath = path.join(process.cwd(), 'database', 'migrations');
|
|
51
|
+
const umzug = new umzug_1.Umzug({
|
|
52
|
+
migrations: {
|
|
53
|
+
glob: ['*.cjs', { cwd: migrationsPath }],
|
|
54
|
+
resolve: ({ name, path: migrationPath, context }) => {
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
56
|
+
const migration = require(migrationPath);
|
|
57
|
+
return {
|
|
58
|
+
name,
|
|
59
|
+
up: async () => migration.up(context.queryInterface, context.Sequelize),
|
|
60
|
+
down: async () => migration.down(context.queryInterface, context.Sequelize),
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
context: {
|
|
65
|
+
queryInterface: sequelize.getQueryInterface(),
|
|
66
|
+
Sequelize: sequelize_1.DataTypes, // 传递 DataTypes 给 migration
|
|
67
|
+
},
|
|
68
|
+
storage: new umzug_1.SequelizeStorage({
|
|
69
|
+
sequelize,
|
|
70
|
+
modelName: 'SequelizeMeta',
|
|
71
|
+
tableName: 'SequelizeMeta',
|
|
72
|
+
schema,
|
|
73
|
+
}),
|
|
74
|
+
logger: console,
|
|
75
|
+
});
|
|
76
|
+
const pending = await umzug.pending();
|
|
77
|
+
if (pending.length > 0) {
|
|
78
|
+
console.log(`⏳ Running ${pending.length} pending migration(s) in schema '${schema}'...`);
|
|
79
|
+
await umzug.up();
|
|
80
|
+
console.log('✓ All migrations completed successfully');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
console.log(`✓ No pending migrations in schema '${schema}'`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Sequelize 实例 Provider
|
|
88
|
+
* 基于配置创建 Sequelize 连接实例
|
|
89
|
+
*/
|
|
90
|
+
exports.sequelizeProvider = {
|
|
91
|
+
provide: sequelize_config_1.SEQUELIZE_INSTANCE,
|
|
92
|
+
useFactory: async (config) => {
|
|
93
|
+
const sequelize = new sequelize_1.Sequelize({
|
|
94
|
+
dialect: config.dialect,
|
|
95
|
+
host: config.host,
|
|
96
|
+
port: config.port,
|
|
97
|
+
username: config.username,
|
|
98
|
+
password: config.password,
|
|
99
|
+
database: config.database,
|
|
100
|
+
logging: config.logging ?? false,
|
|
101
|
+
dialectOptions: config.schema && config.dialect === 'postgres'
|
|
102
|
+
? {
|
|
103
|
+
options: `-c search_path=${config.schema}`,
|
|
104
|
+
}
|
|
105
|
+
: undefined,
|
|
106
|
+
pool: config.pool ?? {
|
|
107
|
+
max: 10,
|
|
108
|
+
min: 0,
|
|
109
|
+
acquire: 30000,
|
|
110
|
+
idle: 10000,
|
|
111
|
+
},
|
|
112
|
+
define: {
|
|
113
|
+
schema: config.schema || 'public', // 默认使用 public schema
|
|
114
|
+
underscored: true, // 自动转换 camelCase ↔ snake_case
|
|
115
|
+
timestamps: false, // 手动管理时间戳字段
|
|
116
|
+
paranoid: false, // 使用 deleted 字段而不是 deletedAt
|
|
117
|
+
},
|
|
118
|
+
hooks: config.schema && config.dialect === 'postgres'
|
|
119
|
+
? {
|
|
120
|
+
afterConnect: async (connection) => {
|
|
121
|
+
await connection.query(`SET search_path TO ${config.schema}`);
|
|
122
|
+
},
|
|
123
|
+
}
|
|
124
|
+
: undefined,
|
|
125
|
+
});
|
|
126
|
+
// 测试连接
|
|
127
|
+
try {
|
|
128
|
+
await sequelize.authenticate();
|
|
129
|
+
console.log('✓ Sequelize connection established successfully');
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
console.error('✗ Unable to connect to the database:', error);
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
// 自动执行迁移(仅 PostgreSQL 和 MySQL 支持)
|
|
136
|
+
if (config.autoMigrate) {
|
|
137
|
+
const supportedDialects = ['postgres', 'mysql'];
|
|
138
|
+
if (supportedDialects.includes(config.dialect)) {
|
|
139
|
+
try {
|
|
140
|
+
await runMigrations(sequelize, config.schema);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
console.error('✗ Migration failed:', error);
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
console.log(`⚠ Auto migration skipped: ${config.dialect} is not supported`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return sequelize;
|
|
152
|
+
},
|
|
153
|
+
inject: [sequelize_config_1.SEQUELIZE_CONFIG],
|
|
154
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/snowflake/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./snowflake.module"), exports);
|
|
18
|
+
__exportStar(require("./snowflake.service"), exports);
|
|
19
|
+
__exportStar(require("./snowflake.config"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snowflake配置接口
|
|
3
|
+
*/
|
|
4
|
+
export interface ISnowflakeConfig {
|
|
5
|
+
/**
|
|
6
|
+
* 应用名称
|
|
7
|
+
* 用于标识不同应用生成的ID
|
|
8
|
+
*/
|
|
9
|
+
app?: string;
|
|
10
|
+
/**
|
|
11
|
+
* 工作节点ID (0-1023)
|
|
12
|
+
* 默认: 1
|
|
13
|
+
*/
|
|
14
|
+
workerId?: number | string;
|
|
15
|
+
/**
|
|
16
|
+
* 数据中心ID (0-31)
|
|
17
|
+
* 默认: 1
|
|
18
|
+
*/
|
|
19
|
+
dataCenterId?: number | string;
|
|
20
|
+
/**
|
|
21
|
+
* 自定义纪元开始时间戳 (milliseconds)
|
|
22
|
+
* 默认: 1514764800000 (2018-01-01)
|
|
23
|
+
*/
|
|
24
|
+
epoch?: number | string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 默认Snowflake配置
|
|
28
|
+
*/
|
|
29
|
+
export declare const DEFAULT_SNOWFLAKE_CONFIG: Partial<ISnowflakeConfig>;
|
|
30
|
+
//# sourceMappingURL=snowflake.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snowflake.config.d.ts","sourceRoot":"","sources":["../../src/snowflake/snowflake.config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAAC,gBAAgB,CAK9D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SNOWFLAKE_CONFIG = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 默认Snowflake配置
|
|
6
|
+
*/
|
|
7
|
+
exports.DEFAULT_SNOWFLAKE_CONFIG = {
|
|
8
|
+
app: 'app',
|
|
9
|
+
workerId: 1,
|
|
10
|
+
dataCenterId: 1,
|
|
11
|
+
epoch: 1514764800000, // 2018-01-01
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* Snowflake模块
|
|
4
|
+
* 提供分布式唯一ID生成服务
|
|
5
|
+
*/
|
|
6
|
+
export declare class SnowflakeModule {
|
|
7
|
+
/**
|
|
8
|
+
* 静态方法:异步配置Snowflake模块
|
|
9
|
+
* 用于根模块注册,支持异步配置加载
|
|
10
|
+
*/
|
|
11
|
+
static forRootAsync(options: {
|
|
12
|
+
useFactory: (...args: any[]) => any;
|
|
13
|
+
inject?: any[];
|
|
14
|
+
imports?: any[];
|
|
15
|
+
}): DynamicModule;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=snowflake.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snowflake.module.d.ts","sourceRoot":"","sources":["../../src/snowflake/snowflake.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;AAK/D;;;GAGG;AACH,qBAEa,eAAe;IAC1B;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE;QAC3B,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;QACpC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;QACf,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;KACjB,GAAG,aAAa;CA+BlB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
var SnowflakeModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SnowflakeModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const snowflake_service_1 = require("./snowflake.service");
|
|
13
|
+
const snowflake_config_1 = require("./snowflake.config");
|
|
14
|
+
const lodash_1 = require("lodash");
|
|
15
|
+
/**
|
|
16
|
+
* Snowflake模块
|
|
17
|
+
* 提供分布式唯一ID生成服务
|
|
18
|
+
*/
|
|
19
|
+
let SnowflakeModule = SnowflakeModule_1 = class SnowflakeModule {
|
|
20
|
+
/**
|
|
21
|
+
* 静态方法:异步配置Snowflake模块
|
|
22
|
+
* 用于根模块注册,支持异步配置加载
|
|
23
|
+
*/
|
|
24
|
+
static forRootAsync(options) {
|
|
25
|
+
return {
|
|
26
|
+
module: SnowflakeModule_1,
|
|
27
|
+
imports: options.imports || [],
|
|
28
|
+
providers: [
|
|
29
|
+
{
|
|
30
|
+
provide: 'SNOWFLAKE_CONFIG',
|
|
31
|
+
useFactory: async (...args) => {
|
|
32
|
+
const config = await options.useFactory(...args);
|
|
33
|
+
const mergedConfig = {
|
|
34
|
+
...snowflake_config_1.DEFAULT_SNOWFLAKE_CONFIG,
|
|
35
|
+
...config,
|
|
36
|
+
};
|
|
37
|
+
mergedConfig.workerId = (0, lodash_1.toNumber)(mergedConfig.workerId || 1);
|
|
38
|
+
mergedConfig.dataCenterId = (0, lodash_1.toNumber)(mergedConfig.dataCenterId || 1);
|
|
39
|
+
mergedConfig.epoch = (0, lodash_1.toNumber)(mergedConfig.epoch || 1514764800000);
|
|
40
|
+
return mergedConfig;
|
|
41
|
+
},
|
|
42
|
+
inject: options.inject || [],
|
|
43
|
+
},
|
|
44
|
+
snowflake_service_1.SnowflakeService, // 直接注册 SnowflakeService 类
|
|
45
|
+
{
|
|
46
|
+
provide: 'APP_SNOWFLAKE',
|
|
47
|
+
useExisting: snowflake_service_1.SnowflakeService, // 使用 useExisting 指向同一实例
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
exports: ['APP_SNOWFLAKE', snowflake_service_1.SnowflakeService], // 同时导出两者
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.SnowflakeModule = SnowflakeModule;
|
|
55
|
+
exports.SnowflakeModule = SnowflakeModule = SnowflakeModule_1 = __decorate([
|
|
56
|
+
(0, common_1.Global)(),
|
|
57
|
+
(0, common_1.Module)({})
|
|
58
|
+
], SnowflakeModule);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ISnowflakeConfig } from './snowflake.config';
|
|
2
|
+
export interface ISnowflakeService {
|
|
3
|
+
nextId(): string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Snowflake服务
|
|
7
|
+
* 提供分布式唯一ID生成能力
|
|
8
|
+
*
|
|
9
|
+
* 使用@sapphire/snowflake库实现,确保生成的ID符合Twitter Snowflake标准
|
|
10
|
+
* 并且可以在JavaScript中安全使用
|
|
11
|
+
*/
|
|
12
|
+
export declare class SnowflakeService implements ISnowflakeService {
|
|
13
|
+
private snowflake;
|
|
14
|
+
constructor(config: ISnowflakeConfig);
|
|
15
|
+
/**
|
|
16
|
+
* 生成下一个唯一ID (字符串类型)
|
|
17
|
+
* @returns 生成的64位ID (string)
|
|
18
|
+
*/
|
|
19
|
+
nextId(): string;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=snowflake.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snowflake.service.d.ts","sourceRoot":"","sources":["../../src/snowflake/snowflake.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,iBAAiB;IAChC,MAAM,IAAI,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,qBACa,gBAAiB,YAAW,iBAAiB;IACxD,OAAO,CAAC,SAAS,CAAY;gBAI3B,MAAM,EAAE,gBAAgB;IAM1B;;;OAGG;IACH,MAAM,IAAI,MAAM;CAGjB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SnowflakeService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const snowflake_1 = require("@sapphire/snowflake");
|
|
18
|
+
/**
|
|
19
|
+
* Snowflake服务
|
|
20
|
+
* 提供分布式唯一ID生成能力
|
|
21
|
+
*
|
|
22
|
+
* 使用@sapphire/snowflake库实现,确保生成的ID符合Twitter Snowflake标准
|
|
23
|
+
* 并且可以在JavaScript中安全使用
|
|
24
|
+
*/
|
|
25
|
+
let SnowflakeService = class SnowflakeService {
|
|
26
|
+
snowflake;
|
|
27
|
+
constructor(config) {
|
|
28
|
+
// 使用@sapphire/snowflake库,传入配置的epoch
|
|
29
|
+
this.snowflake = new snowflake_1.Snowflake(config.epoch);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 生成下一个唯一ID (字符串类型)
|
|
33
|
+
* @returns 生成的64位ID (string)
|
|
34
|
+
*/
|
|
35
|
+
nextId() {
|
|
36
|
+
return this.snowflake.generate().toString();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.SnowflakeService = SnowflakeService;
|
|
40
|
+
exports.SnowflakeService = SnowflakeService = __decorate([
|
|
41
|
+
(0, common_1.Injectable)(),
|
|
42
|
+
__param(0, (0, common_1.Inject)('SNOWFLAKE_CONFIG')),
|
|
43
|
+
__metadata("design:paramtypes", [Object])
|
|
44
|
+
], SnowflakeService);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./swagger.module"), exports);
|
|
18
|
+
__exportStar(require("./swagger.decorators"), exports);
|
|
19
|
+
__exportStar(require("./swagger.config"), exports);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 聚合服务配置
|
|
3
|
+
*/
|
|
4
|
+
export interface IAggregationService {
|
|
5
|
+
/** OpenAPI JSON 端点的完整或相对路径 */
|
|
6
|
+
url: string;
|
|
7
|
+
/** 在下拉菜单中显示的服务名称 */
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 文档聚合配置
|
|
12
|
+
*/
|
|
13
|
+
export interface IAggregationConfig {
|
|
14
|
+
/** 是否启用聚合功能 */
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
/** 聚合文档的访问路径,默认 'api-docs' */
|
|
17
|
+
path?: string;
|
|
18
|
+
/** 要聚合的服务列表 */
|
|
19
|
+
services: IAggregationService[];
|
|
20
|
+
/** 默认显示的服务名称(可选,默认第一个) */
|
|
21
|
+
primaryName?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Swagger配置接口
|
|
25
|
+
*/
|
|
26
|
+
export interface ISwaggerConfig {
|
|
27
|
+
title?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
version?: string;
|
|
30
|
+
path?: string;
|
|
31
|
+
tags?: Array<{
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
}>;
|
|
35
|
+
customSiteTitle?: string;
|
|
36
|
+
customfavIcon?: string;
|
|
37
|
+
customCss?: string;
|
|
38
|
+
/** 文档聚合配置(可选,仅在网关服务中启用) */
|
|
39
|
+
aggregation?: IAggregationConfig;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 默认Snowflake配置
|
|
43
|
+
*/
|
|
44
|
+
export declare const SWAGGER_CONFIG: Partial<ISwaggerConfig>;
|
|
45
|
+
//# sourceMappingURL=swagger.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swagger.config.d.ts","sourceRoot":"","sources":["../../src/swagger/swagger.config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,eAAe;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe;IACf,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,cAAc,CAYlD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SWAGGER_CONFIG = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 默认Snowflake配置
|
|
6
|
+
*/
|
|
7
|
+
exports.SWAGGER_CONFIG = {
|
|
8
|
+
title: 'API',
|
|
9
|
+
description: 'API接口文档',
|
|
10
|
+
version: '1.0',
|
|
11
|
+
path: 'api',
|
|
12
|
+
tags: [],
|
|
13
|
+
customSiteTitle: 'API文档',
|
|
14
|
+
customfavIcon: 'https://nestjs.com/img/logo-small.svg',
|
|
15
|
+
customCss: `
|
|
16
|
+
.topbar-wrapper img {content:url('https://nestjs.com/img/logo-small.svg'); width:50px; height:auto;}
|
|
17
|
+
.swagger-ui .topbar { background-color: #1e1e1e; }
|
|
18
|
+
`,
|
|
19
|
+
};
|