2021-01-04 13:17:16 +08:00
|
|
|
import path from 'path';
|
2021-03-23 10:53:11 +08:00
|
|
|
import dotenv from 'dotenv';
|
2021-04-01 23:51:00 +08:00
|
|
|
import Api from '@nocobase/server/src';
|
|
|
|
import actions from '@nocobase/actions/src';
|
|
|
|
import { middlewares } from '@nocobase/actions/src';
|
2021-01-04 13:17:16 +08:00
|
|
|
|
2021-01-13 16:23:15 +08:00
|
|
|
// @ts-ignore
|
|
|
|
const sync = global.sync || {
|
|
|
|
force: true,
|
2021-01-04 13:17:16 +08:00
|
|
|
alter: {
|
2021-01-13 16:23:15 +08:00
|
|
|
drop: true,
|
2021-01-04 13:17:16 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
console.log('process.env.NOCOBASE_ENV', process.env.NOCOBASE_ENV);
|
|
|
|
|
2021-03-30 17:01:13 +08:00
|
|
|
dotenv.config({
|
|
|
|
path: path.resolve(__dirname, '../../../.env'),
|
|
|
|
});
|
2021-01-04 13:17:16 +08:00
|
|
|
|
|
|
|
const api = Api.create({
|
|
|
|
database: {
|
|
|
|
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,
|
|
|
|
dialect: process.env.DB_DIALECT,
|
|
|
|
dialectOptions: {
|
|
|
|
charset: 'utf8mb4',
|
|
|
|
collate: 'utf8mb4_unicode_ci',
|
|
|
|
},
|
2021-03-26 10:06:36 +08:00
|
|
|
pool: {
|
|
|
|
max: 5,
|
|
|
|
min: 0,
|
|
|
|
acquire: 30000,
|
|
|
|
idle: 10000,
|
|
|
|
},
|
2021-01-20 08:33:47 +08:00
|
|
|
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
|
2021-01-04 13:17:16 +08:00
|
|
|
define: {},
|
|
|
|
sync,
|
|
|
|
},
|
|
|
|
resourcer: {
|
|
|
|
prefix: '/api',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-04-01 09:58:30 +08:00
|
|
|
const plugins = [
|
|
|
|
'@nocobase/plugin-collections',
|
|
|
|
'@nocobase/plugin-action-logs',
|
|
|
|
'@nocobase/plugin-pages',
|
|
|
|
'@nocobase/plugin-users',
|
|
|
|
'@nocobase/plugin-file-manager',
|
|
|
|
'@nocobase/plugin-permissions',
|
|
|
|
'@nocobase/plugin-automations',
|
|
|
|
'@nocobase/plugin-china-region',
|
|
|
|
];
|
2021-01-04 13:17:16 +08:00
|
|
|
|
2021-04-01 09:58:30 +08:00
|
|
|
for (const plugin of plugins) {
|
|
|
|
api.registerPlugin(plugin, [require(`${plugin}/src/server`).default]);
|
|
|
|
}
|
2021-01-04 13:17:16 +08:00
|
|
|
|
|
|
|
export default api;
|