update
This commit is contained in:
@@ -1,17 +1,87 @@
|
||||
import path from 'path';
|
||||
import dotenv from 'dotenv';
|
||||
// import { useConfig } from '@kevisual/use-config/env';
|
||||
import { useConfig } from '@kevisual/use-config';
|
||||
import { useFileStore } from '@kevisual/use-config/file-store';
|
||||
import { minioResources } from './minio.ts';
|
||||
|
||||
export const envFiles = [
|
||||
path.resolve(process.cwd(), process.env.NODE_ENV === 'development' ? '.env.dev' : '.env'),
|
||||
// path.resolve(process.cwd(), '.env'), //
|
||||
];
|
||||
console.log('envFiles', envFiles);
|
||||
export const config = dotenv.config({
|
||||
path: envFiles,
|
||||
override: true,
|
||||
}).parsed;
|
||||
// const config = useConfig();
|
||||
// export const config = process.env;
|
||||
// console.log('config', config);
|
||||
export const config = useConfig() as any;
|
||||
export const port = config.PORT || 4005;
|
||||
export const fileStore = useFileStore('pages');
|
||||
type ConfigType = {
|
||||
api: {
|
||||
/**
|
||||
* API host address
|
||||
*/
|
||||
host: string;
|
||||
path?: string;
|
||||
port?: number;
|
||||
};
|
||||
apiList: {
|
||||
path: string;
|
||||
/**
|
||||
* url或者相对路径
|
||||
*/
|
||||
target: string;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
type?: 'static' | 'dynamic' | 'minio';
|
||||
}[];
|
||||
proxy: {
|
||||
port?: number;
|
||||
/**
|
||||
* self domain kevisual.xiongxiao.me
|
||||
*/
|
||||
domain: string;
|
||||
/**
|
||||
* resources path
|
||||
* https://minio.xiongxiao.me/resources
|
||||
*/
|
||||
resources: string;
|
||||
/**
|
||||
* allow origin xiongxiao.me zxj.im silkyai.cn
|
||||
* 允许跨域访问的地址
|
||||
*/
|
||||
allowedOrigin: string[];
|
||||
};
|
||||
stat: {
|
||||
/**
|
||||
* 统计网站ID
|
||||
*/
|
||||
websiteId: string;
|
||||
};
|
||||
redis?: {
|
||||
host: string;
|
||||
port: number;
|
||||
password?: string;
|
||||
};
|
||||
};
|
||||
export const myConfig: ConfigType = {
|
||||
api: {
|
||||
host: config.API_HOST,
|
||||
path: config.API_PATH,
|
||||
port: config.PROXY_PORT,
|
||||
},
|
||||
apiList: [
|
||||
// {
|
||||
// path: '/api',
|
||||
// target: config.API_HOST,
|
||||
// },
|
||||
{
|
||||
path: '/client',
|
||||
target: config.API_CLIENT_HOST || 'http://localhost:51015',
|
||||
},
|
||||
],
|
||||
proxy: {
|
||||
port: config.PROXY_PORT,
|
||||
domain: config.PROXY_DOMAIN,
|
||||
resources: minioResources,
|
||||
allowedOrigin: (config.PROXY_ALLOWED_ORIGINS as string)?.split(',') || [],
|
||||
},
|
||||
redis: {
|
||||
host: config.REDIS_HOST,
|
||||
port: config.REDIS_PORT,
|
||||
password: config.REDIS_PASSWORD,
|
||||
},
|
||||
stat: {
|
||||
websiteId: config.DATA_WEBSITE_ID,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user