setup application, server, and configs

This commit is contained in:
ItsMalma
2025-11-03 21:28:16 +07:00
parent 2769bdd894
commit 9aa0de17ee
12 changed files with 182 additions and 17 deletions

48
src/application.ts Normal file
View File

@@ -0,0 +1,48 @@
import { serverConfig } from "@/configs/server.config";
import compression from "compression";
import cors from "cors";
import express from "express";
import helmet from "helmet";
export class Application {
private readonly _app: express.Application;
public constructor() {
this._app = express();
}
public initializeMiddlewares() {
this._app.use(helmet());
this._app.use(cors());
this._app.use(compression());
this._app.use(express.json());
this._app.use(express.urlencoded());
}
public initializeRouters() {
// this._app.use("/countries");
// this._app.use("/cities");
// this._app.use("/airlines");
// this._app.use("/airports");
// this._app.use("/flights");
// this._app.use("/hotel-facilities");
// this._app.use("/hotels");
// this._app.use("/transportations");
// this._app.use("/packages");
}
public initializeErrorHandlers() {}
public run() {
const port = serverConfig.port;
const host = serverConfig.host;
this._app.listen(port, host, (err) => {
if (err) {
console.log(`Failed to listen server: ${err.message}`);
} else {
console.log(`Server listening at ${host}:${port}`);
}
});
}
}