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-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';
|
2022-07-06 18:59:46 +00:00
|
|
|
|
|
|
|
const APP_NAME: string = 'mail';
|
|
|
|
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);
|
2022-04-11 20:07:13 +00:00
|
|
|
|
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();
|