oneuptime/Identity/Index.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

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';
import StatusPageAuthenticationAPI from './API/StatusPageAuthentication';
2023-03-10 15:01:04 +00:00
import Redis from 'CommonServer/Infrastructure/Redis';
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-03-05 19:02:04 +00:00
app.use([`/${APP_NAME}`, '/'], SsoAPI);
2022-12-19 09:39:55 +00:00
app.use(
[`/${APP_NAME}/status-page`, '/staus-page'],
StatusPageAuthenticationAPI
);
2022-05-25 18:16:37 +00:00
2022-06-03 14:03:56 +00:00
const init: Function = 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
// connect redis
await Redis.connect();
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);
}
};
init();