
controllers, repositories, services and associated tests for: Deed types, Deed, Document types, Users and Customers --------- Co-authored-by: Vincent Alamelle <vincent.alamelle@smart-chain.fr> Co-authored-by: OxSaitama <arnaud.daubernatali@smart-chain.fr>
40 lines
887 B
TypeScript
40 lines
887 B
TypeScript
import express, { Express, Router } from "express";
|
|
import { Service } from "typedi";
|
|
import ServerInterface, { IConfig } from "./ServerInterface";
|
|
|
|
@Service()
|
|
export default class ExpressServer implements ServerInterface {
|
|
public router: Express = express();
|
|
private subRouter: Router = express.Router();
|
|
|
|
public getRouter(): Router {
|
|
return this.subRouter;
|
|
}
|
|
|
|
protected getMainRouter(): Express {
|
|
return this.router;
|
|
}
|
|
|
|
public init(config: IConfig) {
|
|
this.router.use(...config.middlwares);
|
|
this.router.use(config.rootUrl, this.subRouter);
|
|
if (config.errorHandler) this.router.use(config.errorHandler);
|
|
return this;
|
|
}
|
|
|
|
public listen() {
|
|
return this.router.listen(3001, () => {
|
|
console.table(
|
|
[
|
|
{
|
|
"Entry label": "le coffre API",
|
|
Port: 3001,
|
|
"Root url": "/api",
|
|
},
|
|
],
|
|
["Entry label", "Port", "Root url"],
|
|
);
|
|
});
|
|
}
|
|
}
|