oneuptime/Identity/Index.ts

28 lines
804 B
TypeScript
Raw Normal View History

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';
2022-05-23 11:45:32 +00:00
import AuthenticationAPI from './API/AuthenticationAPI';
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);
const init = async () => {
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()
);
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();