tachybase_todo/packages/api/src/index.ts

26 lines
705 B
TypeScript
Raw Normal View History

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-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-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-07-23 21:28:57 +08:00
await api.database.getModel('collections').load({ skipExisting: true });
2021-04-07 17:37:14 +08:00
api.listen(process.env.API_PORT, () => {
console.log(`http://localhost:${process.env.API_PORT}/`);
});
})();