2022-07-08 20:00:56 +00:00
|
|
|
import 'ejs';
|
2022-07-06 18:59:46 +00:00
|
|
|
import Express, { ExpressApplication } from 'CommonServer/Utils/Express';
|
2022-05-24 16:46:21 +00:00
|
|
|
import App from 'CommonServer/Utils/StartServer';
|
2023-04-19 20:13:54 +00:00
|
|
|
import Redis from 'CommonServer/Infrastructure/Redis';
|
2022-05-24 16:46:21 +00:00
|
|
|
|
2022-04-19 19:11:44 +00:00
|
|
|
// API
|
2022-04-20 20:14:44 +00:00
|
|
|
import MailAPI from './API/Mail';
|
2023-06-08 12:34:34 +00:00
|
|
|
import SmsAPI from './API/SMS';
|
2023-06-16 13:00:40 +00:00
|
|
|
import CallAPI from './API/Call';
|
2023-04-19 20:13:54 +00:00
|
|
|
import SMTPConfigAPI from './API/SMTPConfig';
|
2022-07-08 20:00:56 +00:00
|
|
|
import logger from 'CommonServer/Utils/Logger';
|
2023-04-19 20:13:54 +00:00
|
|
|
import { PostgresAppInstance } from 'CommonServer/Infrastructure/PostgresDatabase';
|
2023-05-17 19:15:07 +00:00
|
|
|
// import handlebars loader.
|
2023-05-17 18:25:01 +00:00
|
|
|
import './Utils/Handlebars';
|
|
|
|
|
2023-06-06 20:17:58 +00:00
|
|
|
const APP_NAME: string = 'notification';
|
2022-07-06 18:59:46 +00:00
|
|
|
const app: ExpressApplication = Express.getExpressApp();
|
2022-04-19 19:11:44 +00:00
|
|
|
|
2022-05-24 16:46:21 +00:00
|
|
|
app.use([`/${APP_NAME}/email`, '/email'], MailAPI);
|
2023-06-08 12:34:34 +00:00
|
|
|
app.use([`/${APP_NAME}/sms`, '/sms'], SmsAPI);
|
2023-06-16 13:00:40 +00:00
|
|
|
app.use([`/${APP_NAME}/call`, '/call'], CallAPI);
|
2023-04-19 20:13:54 +00:00
|
|
|
app.use([`/${APP_NAME}/smtp-config`, '/smtp-config'], SMTPConfigAPI);
|
|
|
|
|
2022-07-06 18:59:46 +00:00
|
|
|
const init: Function = async (): Promise<void> => {
|
|
|
|
try {
|
|
|
|
// init the app
|
|
|
|
await App(APP_NAME);
|
2023-04-19 20:13:54 +00:00
|
|
|
|
|
|
|
// connect to the database.
|
|
|
|
await PostgresAppInstance.connect(
|
|
|
|
PostgresAppInstance.getDatasourceOptions()
|
|
|
|
);
|
|
|
|
|
|
|
|
// connect redis
|
|
|
|
await Redis.connect();
|
2022-07-06 18:59:46 +00:00
|
|
|
} catch (err) {
|
|
|
|
logger.error('App Init Failed:');
|
|
|
|
logger.error(err);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
init();
|