2022-07-06 18:59:46 +00:00
|
|
|
import 'ejs';
|
2022-05-25 18:16:37 +00:00
|
|
|
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-03-05 19:02:04 +00:00
|
|
|
import AuthenticationAPI from './API/Authentication';
|
|
|
|
import SsoAPI from './API/SSO';
|
2023-08-31 14:34:46 +00:00
|
|
|
import ResellerAPI from './API/Reseller';
|
2023-03-13 12:23:08 +00:00
|
|
|
import StatusPageSsoAPI from './API/StatusPageSSO';
|
2023-03-05 19:02:04 +00:00
|
|
|
import StatusPageAuthenticationAPI from './API/StatusPageAuthentication';
|
2023-03-10 15:01:04 +00:00
|
|
|
import Redis from 'CommonServer/Infrastructure/Redis';
|
2023-08-19 19:49:24 +00:00
|
|
|
import { ClickhouseAppInstance } from 'CommonServer/Infrastructure/ClickhouseDatabase';
|
2023-03-05 19:02:04 +00:00
|
|
|
|
2022-05-25 18:16:37 +00:00
|
|
|
const app: ExpressApplication = Express.getExpressApp();
|
2022-05-24 16:46:21 +00:00
|
|
|
|
2022-05-25 18:16:37 +00:00
|
|
|
const APP_NAME: string = 'identity';
|
2022-05-24 16:46:21 +00:00
|
|
|
|
2022-05-25 18:16:37 +00:00
|
|
|
app.use([`/${APP_NAME}`, '/'], AuthenticationAPI);
|
2022-12-19 14:09:21 +00:00
|
|
|
|
2023-08-31 14:34:46 +00:00
|
|
|
app.use([`/${APP_NAME}`, '/'], ResellerAPI);
|
|
|
|
|
2023-03-05 19:02:04 +00:00
|
|
|
app.use([`/${APP_NAME}`, '/'], SsoAPI);
|
|
|
|
|
2023-03-13 12:23:08 +00:00
|
|
|
app.use([`/${APP_NAME}`, '/'], StatusPageSsoAPI);
|
|
|
|
|
2022-12-19 09:39:55 +00:00
|
|
|
app.use(
|
2023-06-09 12:58:56 +00:00
|
|
|
[`/${APP_NAME}/status-page`, '/status-page'],
|
2022-12-19 09:39:55 +00:00
|
|
|
StatusPageAuthenticationAPI
|
|
|
|
);
|
2022-05-25 18:16:37 +00:00
|
|
|
|
2023-08-10 17:25:15 +00:00
|
|
|
const init: () => Promise<void> = async (): Promise<void> => {
|
2022-05-25 18:16:37 +00:00
|
|
|
try {
|
|
|
|
// init the app
|
|
|
|
await App(APP_NAME);
|
|
|
|
// connect to the database.
|
2022-05-25 18:24:43 +00:00
|
|
|
await PostgresAppInstance.connect(
|
|
|
|
PostgresAppInstance.getDatasourceOptions()
|
|
|
|
);
|
2023-03-10 15:01:04 +00:00
|
|
|
|
2023-03-10 15:04:37 +00:00
|
|
|
// connect redis
|
|
|
|
await Redis.connect();
|
2023-08-19 19:49:24 +00:00
|
|
|
|
2023-08-21 11:04:28 +00:00
|
|
|
await ClickhouseAppInstance.connect(
|
|
|
|
ClickhouseAppInstance.getDatasourceOptions()
|
|
|
|
);
|
2022-05-25 18:16:37 +00:00
|
|
|
} catch (err) {
|
2022-05-25 18:24:43 +00:00
|
|
|
logger.error('App Init Failed:');
|
2022-05-25 18:16:37 +00:00
|
|
|
logger.error(err);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-08-10 18:00:27 +00:00
|
|
|
init().catch((err: Error) => {
|
|
|
|
logger.error(err);
|
|
|
|
});
|