2023-05-02 14:29:22 +00:00
|
|
|
import 'ejs';
|
|
|
|
import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabase';
|
|
|
|
import Express, { ExpressApplication } from 'CommonServer/Utils/Express';
|
|
|
|
import logger from 'CommonServer/Utils/Logger';
|
2022-05-24 16:46:21 +00:00
|
|
|
import App from 'CommonServer/Utils/StartServer';
|
2023-05-02 14:29:22 +00:00
|
|
|
import AliveAPI from './API/Alive';
|
|
|
|
import RegisterAPI from './API/Register';
|
2023-05-10 17:53:36 +00:00
|
|
|
import MonitorAPI from './API/Monitor';
|
2023-05-11 15:29:38 +00:00
|
|
|
import ProbeAPI from './API/Probe';
|
2023-07-29 15:21:47 +00:00
|
|
|
import IncomingRequestAPI from './API/IncomingRequest';
|
2022-05-24 16:46:21 +00:00
|
|
|
|
2023-05-02 14:29:22 +00:00
|
|
|
import Redis from 'CommonServer/Infrastructure/Redis';
|
2022-01-10 06:48:35 +00:00
|
|
|
|
2023-05-02 14:29:22 +00:00
|
|
|
const app: ExpressApplication = Express.getExpressApp();
|
2022-04-20 20:14:44 +00:00
|
|
|
|
2023-05-02 14:29:22 +00:00
|
|
|
const APP_NAME: string = 'probe-api';
|
2022-01-10 06:48:35 +00:00
|
|
|
|
2023-05-02 14:29:22 +00:00
|
|
|
app.use([`/${APP_NAME}`, '/'], AliveAPI);
|
|
|
|
app.use([`/${APP_NAME}`, '/'], RegisterAPI);
|
2023-05-10 17:53:36 +00:00
|
|
|
app.use([`/${APP_NAME}`, '/'], MonitorAPI);
|
2023-05-11 15:29:38 +00:00
|
|
|
app.use([`/${APP_NAME}`, '/'], ProbeAPI);
|
2023-07-29 15:21:47 +00:00
|
|
|
app.use([`/${APP_NAME}`, '/'], IncomingRequestAPI);
|
2023-05-02 14:29:22 +00:00
|
|
|
|
2023-08-10 17:25:15 +00:00
|
|
|
const init: () => Promise<void> = async (): Promise<void> => {
|
2023-05-02 14:29:22 +00:00
|
|
|
try {
|
|
|
|
// init the app
|
|
|
|
await App(APP_NAME);
|
|
|
|
// connect to the database.
|
|
|
|
await PostgresAppInstance.connect(
|
|
|
|
PostgresAppInstance.getDatasourceOptions()
|
|
|
|
);
|
|
|
|
|
|
|
|
// connect redis
|
|
|
|
await Redis.connect();
|
|
|
|
} catch (err) {
|
|
|
|
logger.error('App Init Failed:');
|
|
|
|
logger.error(err);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
init();
|