|
|
|
@ -1,17 +1,9 @@
|
|
|
|
|
import express, { Application } from 'express';
|
|
|
|
|
// import compression from 'compression';
|
|
|
|
|
import cors from 'cors';
|
|
|
|
|
// import db from './database';
|
|
|
|
|
// import morgan from 'morgan';
|
|
|
|
|
import Controller from './controller/Icontroller';
|
|
|
|
|
// import ErrorMiddleware from './middleware/error.middleware';
|
|
|
|
|
import bodyParser from 'body-parser';
|
|
|
|
|
import mongoose from 'mongoose';
|
|
|
|
|
|
|
|
|
|
// to secure
|
|
|
|
|
// import helmet from 'helmet';
|
|
|
|
|
|
|
|
|
|
import http from 'http';
|
|
|
|
|
import cookieParser from 'cookie-parser';
|
|
|
|
|
|
|
|
|
|
class App {
|
|
|
|
@ -30,20 +22,16 @@ class App {
|
|
|
|
|
this.initialiseMiddleware();
|
|
|
|
|
this.initialiseControllers(controllers);
|
|
|
|
|
|
|
|
|
|
// this.initialiseErrorHandling();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private initialiseMiddleware(): void {
|
|
|
|
|
// this.express.use(helmet());
|
|
|
|
|
this.express.use(cors());
|
|
|
|
|
this.express.use(cookieParser());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.express.use(morgan('dev'));
|
|
|
|
|
this.express.use(express.json());
|
|
|
|
|
this.express.use(express.urlencoded({ extended: false }));
|
|
|
|
|
// this.express.use(compression());
|
|
|
|
|
// mine
|
|
|
|
|
|
|
|
|
|
this.express.use(bodyParser.json());
|
|
|
|
|
this.express.use(bodyParser.urlencoded({
|
|
|
|
|
extended: true
|
|
|
|
@ -60,9 +48,7 @@ class App {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// private initialiseErrorHandling(): void {
|
|
|
|
|
// this.express.use(ErrorMiddleware);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public listen(): void {
|
|
|
|
|
const server = this.express.listen(this.port, () => {
|
|
|
|
|