oneuptime/AdminDashboard/Serve.ts

39 lines
1.0 KiB
TypeScript
Raw Normal View History

2023-08-25 14:20:00 +00:00
import App from 'CommonServer/Utils/StartServer';
import Express, { ExpressApplication } from 'CommonServer/Utils/Express';
import logger from 'CommonServer/Utils/Logger';
import { PromiseVoidFunction } from 'Common/Types/FunctionTypes';
2023-08-25 14:20:00 +00:00
2023-09-05 09:32:18 +00:00
export const APP_NAME: string = 'admin';
2023-08-25 14:20:00 +00:00
const app: ExpressApplication = Express.getExpressApp();
const init: PromiseVoidFunction = async (): Promise<void> => {
2023-08-25 14:20:00 +00:00
try {
// init the app
await App.init({
appName: APP_NAME,
port: undefined,
isFrontendApp: true,
statusOptions: {
liveCheck: async () => {},
readyCheck: async () => {},
},
});
// add default routes
await App.addDefaultRoutes();
2023-08-25 14:20:00 +00:00
} catch (err) {
logger.error('App Init Failed:');
logger.error(err);
2023-10-04 18:22:25 +00:00
throw err;
2023-08-25 14:20:00 +00:00
}
};
init().catch((err: Error) => {
logger.error(err);
2023-10-04 18:22:25 +00:00
logger.info('Exiting node process');
2023-09-27 19:48:50 +00:00
process.exit(1);
2023-08-25 14:20:00 +00:00
});
export default app;