* fix: test cases * fix env used by file manager * default value of process.env.LOCAL_STORAGE_BASE_URL * use workspace dependencies * refactor some env to adapt more scenario * fix reviewing issues * fix env default value * update umi config * bugfix * fix shared cache Co-authored-by: chenos <chenlinxh@gmail.com>
87 lines
2.0 KiB
TypeScript
87 lines
2.0 KiB
TypeScript
import Server from '@nocobase/server';
|
|
import path from 'path';
|
|
|
|
const start = Date.now();
|
|
|
|
const api = new Server({
|
|
database: process.env.DB_DIALECT === 'sqlite' ? {
|
|
dialect: process.env.DB_DIALECT as any,
|
|
storage: path.resolve(process.cwd(), './db.sqlite'),
|
|
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
|
|
define: {},
|
|
sync: {
|
|
force: false,
|
|
alter: {
|
|
drop: false,
|
|
},
|
|
},
|
|
} : {
|
|
username: process.env.DB_USER,
|
|
password: process.env.DB_PASSWORD,
|
|
database: process.env.DB_DATABASE,
|
|
host: process.env.DB_HOST,
|
|
port: process.env.DB_PORT as any,
|
|
dialect: process.env.DB_DIALECT as any,
|
|
dialectOptions: {
|
|
charset: 'utf8mb4',
|
|
collate: 'utf8mb4_unicode_ci',
|
|
},
|
|
pool: {
|
|
max: 5,
|
|
min: 0,
|
|
acquire: 60000,
|
|
idle: 10000,
|
|
},
|
|
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
|
|
define: {},
|
|
sync: {
|
|
force: false,
|
|
alter: {
|
|
drop: false,
|
|
},
|
|
},
|
|
},
|
|
resourcer: {
|
|
prefix: process.env.API_BASE_PATH || '/api/',
|
|
},
|
|
});
|
|
|
|
const plugins = [
|
|
// '@nocobase/plugin-multi-apps',
|
|
'@nocobase/plugin-ui-router',
|
|
'@nocobase/plugin-ui-schema',
|
|
'@nocobase/plugin-collections',
|
|
'@nocobase/plugin-users',
|
|
'@nocobase/plugin-action-logs',
|
|
'@nocobase/plugin-file-manager',
|
|
'@nocobase/plugin-permissions',
|
|
'@nocobase/plugin-export',
|
|
'@nocobase/plugin-system-settings',
|
|
'@nocobase/plugin-china-region',
|
|
];
|
|
|
|
const libDir = __filename.endsWith('.ts') ? 'src' : 'lib';
|
|
|
|
for (const plugin of plugins) {
|
|
api.plugin(
|
|
require(`${plugin}/${libDir}/server`).default,
|
|
);
|
|
}
|
|
|
|
api.plugin(
|
|
require(`@nocobase/plugin-client/${libDir}/server`).default, {
|
|
dist: process.env.APP_DIST || path.resolve(process.cwd(), './dist'),
|
|
lang: process.env.APP_LANG,
|
|
// importDemo: true,
|
|
});
|
|
|
|
if (process.argv.length < 3) {
|
|
// @ts-ignore
|
|
process.argv.push('start', '--port', process.env.API_PORT);
|
|
}
|
|
|
|
|
|
api.parse(process.argv).then(() => {
|
|
console.log(`Start-up time: ${(Date.now() - start) / 1000}s`);
|
|
});
|