tachybase_todo/packages/api/src/app.ts

56 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-04-06 20:05:56 +08:00
import Api from '@nocobase/server';
2021-01-04 13:17:16 +08:00
// @ts-ignore
const sync = global.sync || {
2021-04-07 17:10:52 +08:00
force: false,
2021-01-04 13:17:16 +08:00
alter: {
2021-04-07 17:10:52 +08:00
drop: false,
2021-01-04 13:17:16 +08:00
},
};
console.log('process.env.NOCOBASE_ENV', process.env.NOCOBASE_ENV);
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,
},
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) {
2021-04-06 20:05:56 +08:00
api.registerPlugin(plugin, [require(`${plugin}/${__filename.endsWith('.ts') ? 'src' : 'lib'}/server`).default]);
2021-04-01 09:58:30 +08:00
}
2021-01-04 13:17:16 +08:00
export default api;