setup application, server, and configs
This commit is contained in:
48
src/application.ts
Normal file
48
src/application.ts
Normal 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}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user