UNPKG

@agatee/cli

Version:

CLI for Agatee App

6 lines (5 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.serverStarterCode = void 0; var serverStarterCode = function (appName) { /*javascript */ return "\nimport http from 'http';\nimport express, { Application } from 'express';\nimport { Injectable } from '@agatee/core';\n\nimport { environment } from '../environments';\n\n@Injectable()\nexport class Server {\n public app: Application = express();\n public httpServer: http.Server;\n public PORT: string|number;\n constructor() {\n this.PORT = environment.PORT;\n this.httpServer = http.createServer(this.app);\n }\n\n useMiddlewares(middlewares: any[]) {\n middlewares.forEach((middleware: any) => {\n this.app.use(middleware);\n })\n }\n\n use(...args: any) {\n this.app.use(...args);\n }\n\n start() {\n this.httpServer.listen(this.PORT, () => {\n console.log('App " + appName + " running on port', this.PORT);\n })\n }\n\n setPort(port: number) {\n this.PORT = port;\n }\n}\n"; }; exports.serverStarterCode = serverStarterCode;