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-04-07 17:10:52 +08:00
|
|
|
await api.loadPlugins();
|
2021-01-07 09:31:26 +08:00
|
|
|
|
2021-04-07 17:10:52 +08:00
|
|
|
if (process.env.NOCOBASE_ENV === 'demo') {
|
|
|
|
api.resourcer.use(middlewares.demoBlacklistedActions({
|
|
|
|
emails: [process.env.ADMIN_EMAIL],
|
|
|
|
}));
|
|
|
|
}
|
2021-01-06 17:38:08 +08:00
|
|
|
|
2021-04-07 17:10:52 +08:00
|
|
|
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-06 20:05:56 +08:00
|
|
|
|
2021-04-07 17:37:14 +08:00
|
|
|
api.listen(process.env.API_PORT, () => {
|
|
|
|
console.log(`http://localhost:${process.env.API_PORT}/`);
|
|
|
|
});
|
2020-11-11 15:23:39 +08:00
|
|
|
})();
|