import express , { Router , Request , Response , response } from "express" ; import { Environment } from "./Configuration/Environment" ; import { RoutingEngine } from "./Routing/RoutingEngine" ; import cors from "cors" ; import firebase from "firebase" ; import bodyParser = require ( "body-parser" ) ; export abstract class Server { constructor ( private port = 3000 , private app = express ( ) , protected routingEngine = new RoutingEngine ( ) ) { } public WithCorsSupport ( ) { this . app . use ( cors ( ) ) ; return this ; } public Start ( ) { this . app . use ( bodyParser . json ( ) ) ; this . app . use ( bodyParser . urlencoded ( { extended : true } ) ) ; const router = express . Router ( ) ; this . AddRouting ( router ) ; this . app . use ( router ) ; this . app . listen ( this . port , ( ) => console . log ( `logged onto people server at ${ this . port }` ) ) ; } protected AddRouting ( router ) { } public WithDatabase ( ) { firebase . initializeApp ( Environment . fireBase ) ; return this ; } }