import express, { Express } from 'express'; import cors from 'cors'; import * as router from './router'; import { BeforeEach, ErrorHandler } from './middleware'; import { Services } from '../../app'; import { ServerConfig } from '../../config'; class Server { private app: Express; private config: ServerConfig; constructor(config: ServerConfig, services: Services) { this.config = config; this.app = express(); this.app.use(express.json()); this.app.use(cors()); this.app.use(BeforeEach()); this.app.use(router.getRoutes(services)); this.app.use(ErrorHandler()); } start(func: () => void): void { this.app.listen(this.config.port, func); } } export default Server;