Files
certd/packages/ui/certd-server/src/config/config.default.ts
T

100 lines
2.3 KiB
TypeScript
Raw Normal View History

2024-07-15 00:30:33 +08:00
import { MidwayConfig } from '@midwayjs/core';
// import { join } from 'path';
// import { dirname } from 'node:path';
// import { fileURLToPath } from 'node:url';
// // const __filename = fileURLToPath(import.meta.url);
// const __dirname = dirname(fileURLToPath(import.meta.url));
2023-01-29 13:44:19 +08:00
2024-07-17 01:30:00 +08:00
// eslint-disable-next-line node/no-extraneous-import
2024-07-15 00:30:33 +08:00
import { FlywayHistory } from '@certd/midway-flyway-js';
import { UserEntity } from '../modules/authority/entity/user.js';
import { PipelineEntity } from '../modules/pipeline/entity/pipeline.js';
2023-05-26 16:18:24 +08:00
//import { logger } from '../utils/logger';
2023-05-25 15:17:58 +08:00
// load .env file in process.cwd
2024-07-15 00:30:33 +08:00
import { mergeConfig } from './loader.js';
import { Keys } from './keys.js';
2024-07-17 01:30:00 +08:00
const env = process.env.NODE_ENV || 'development';
const keys = Keys.load();
2023-06-26 12:26:59 +08:00
const development = {
keys: keys.cookieKeys,
2023-01-29 13:44:19 +08:00
koa: {
port: 7001,
},
2023-05-25 13:43:32 +08:00
staticFile: {
2023-07-03 09:15:52 +08:00
usePrecompiledGzip: true,
buffer: true,
2023-07-03 17:57:26 +08:00
maxAge: 30 * 24 * 60 * 60 * 1000,
2023-07-03 09:15:52 +08:00
gzip: true,
2023-05-25 13:43:32 +08:00
dirs: {
default: {
prefix: '/',
dir: 'public',
2023-05-25 15:17:58 +08:00
alias: {
'/': '/index.html',
},
2023-05-25 13:43:32 +08:00
},
},
},
cron: {
2024-08-13 20:30:42 +08:00
//启动时立即触发一次
immediateTriggerOnce: false,
2024-08-13 20:30:42 +08:00
//启动时仅注册adminid=1)用户的
onlyAdminUser: false,
},
2023-01-29 13:44:19 +08:00
/**
* 演示环境
*/
preview: {
enabled: false,
},
/**
* 数据库
*/
typeorm: {
dataSource: {
default: {
/**
* 单数据库实例
*/
2024-07-20 18:04:07 +08:00
type: 'better-sqlite3',
database: './data/db.sqlite',
2023-01-29 13:44:19 +08:00
synchronize: false, // 如果第一次使用,不存在表,有同步的需求可以写 true
logging: false,
2023-01-29 13:44:19 +08:00
// 配置实体模型 或者 entities: '/entity',
2024-07-15 00:30:33 +08:00
entities: ['**/modules/*/entity/*.ts', '**/entity/*.js', '**/entity/*.d.ts', PipelineEntity, FlywayHistory, UserEntity],
2023-01-29 13:44:19 +08:00
},
},
},
/**
* 自动升级数据库脚本
*/
flyway: {
scriptDir: './db/migration',
2023-01-29 13:44:19 +08:00
},
2023-06-28 09:44:35 +08:00
auth: {
2023-01-29 13:44:19 +08:00
jwt: {
secret: keys.jwtKey,
2023-06-29 08:56:09 +08:00
expire: 7 * 24 * 60 * 60, //单位秒
2023-01-29 13:44:19 +08:00
},
},
2023-06-28 15:16:19 +08:00
certd: {
fileRootDir: './data/files',
2023-06-28 15:16:19 +08:00
},
system: {
resetAdminPasswd: false,
},
2024-08-23 13:15:06 +08:00
plus: {
serverBaseUrl: 'http://127.0.0.1:11007',
},
2023-01-29 13:44:19 +08:00
} as MidwayConfig;
mergeConfig(development, 'development');
2024-07-17 01:30:00 +08:00
mergeConfig(development, env);
2024-07-15 00:30:33 +08:00
2023-06-26 12:26:59 +08:00
export default development;