oneuptime/LinkShortener/Index.ts

31 lines
839 B
TypeScript
Raw Normal View History

2023-07-01 12:08:50 +00:00
import Express, { ExpressApplication } from 'CommonServer/Utils/Express';
2023-07-01 10:57:53 +00:00
import App from 'CommonServer/Utils/StartServer';
import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabase';
import logger from 'CommonServer/Utils/Logger';
2023-07-29 23:03:00 +00:00
import LinkShortenerAPI from './API/LinkShortener';
2023-07-01 10:57:53 +00:00
const APP_NAME: string = 'l';
2023-07-01 12:08:50 +00:00
const app: ExpressApplication = Express.getExpressApp();
2023-07-01 11:58:59 +00:00
2023-07-29 23:03:00 +00:00
app.use([`/${APP_NAME}/`, '/'], LinkShortenerAPI);
2023-07-01 11:58:59 +00:00
2023-07-01 10:57:53 +00:00
const init: Function = async (): Promise<void> => {
try {
// connect to the database.
await PostgresAppInstance.connect(
PostgresAppInstance.getDatasourceOptions()
);
// init the app
await App(APP_NAME);
} catch (err) {
logger.error('App Init Failed:');
logger.error(err);
}
};
init();
export default app;