oneuptime/LinkShortener/Index.ts

33 lines
900 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-08-10 17:25:15 +00:00
const init: () => Promise<void> = async (): Promise<void> => {
2023-07-01 10:57:53 +00:00
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);
}
};
2023-08-10 18:00:27 +00:00
init().catch((err: Error) => {
logger.error(err);
});
2023-07-01 10:57:53 +00:00
export default app;