2021-01-13 16:23:15 +08:00
|
|
|
import api from './app';
|
2021-04-07 17:10:52 +08:00
|
|
|
import { middlewares } from '@nocobase/server';
|
2020-12-15 14:32:56 +08:00
|
|
|
|
2020-12-18 19:54:53 +08:00
|
|
|
(async () => {
|
2021-04-07 17:10:52 +08:00
|
|
|
api.resourcer.use(middlewares.actionParams());
|
2021-01-06 17:38:08 +08:00
|
|
|
|
2021-09-05 14:17:45 +08:00
|
|
|
api.on('plugins.afterLoad', async () => {
|
|
|
|
console.log('plugins.afterLoad')
|
|
|
|
if (process.env.NOCOBASE_ENV === 'demo') {
|
|
|
|
api.resourcer.use(middlewares.demoBlacklistedActions({
|
|
|
|
emails: [process.env.ADMIN_EMAIL],
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
api.use(middlewares.appDistServe({
|
|
|
|
root: process.env.APP_DIST,
|
|
|
|
useStaticServer: !(process.env.APP_USE_STATIC_SERVER === 'false' || !process.env.APP_USE_STATIC_SERVER),
|
2021-04-07 17:10:52 +08:00
|
|
|
}));
|
2021-04-07 17:37:14 +08:00
|
|
|
});
|
2021-09-05 14:17:45 +08:00
|
|
|
|
|
|
|
const start = Date.now();
|
|
|
|
await api.start(process.env.API_PORT);
|
|
|
|
console.log(api.database.getTables().map(t => t.getName()));
|
|
|
|
console.log(`Start-up time: ${(Date.now() - start) / 1000}s`);
|
|
|
|
console.log(`http://localhost:${process.env.API_PORT}/`);
|
2020-11-11 15:23:39 +08:00
|
|
|
})();
|