@agatee/cli
Version:
CLI for Agatee App
6 lines (5 loc) • 1.19 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.appStarterCode = void 0;
var appStarterCode = function (appName, option) { /*javascript*/ return "\n\nimport { GatModule } from \"@agatee/core\";\nimport { urlencoded, json } from \"express\";\n\nimport { Server } from \"./server\";\nimport cors from 'cors';\n\n" + (option.apiStyle === 'graphql' ? "import { GatGraphqlModule } from \"./graphql\";\n" : '') + "\nconst middlewares = [\n urlencoded({extended: false}),\n json(),\n cors(),\n function(req: any, res: any, next: any) {\n res.header(\"Access-Control-Allow-Origin\", \"*\");\n res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, REDIRECT');\n res.header(\"Access-Control-Allow-Headers\", \"Origin, X-Requested-With, Content-Type, Accept, Authorization\");\n next();\n }\n]\n\n@GatModule({\n " + (option.apiStyle === 'graphql' ? "imports: [GatGraphqlModule]," : '') + "\n routes: [],\n middlewares\n})\nexport class AppModule {\n constructor(private server: Server) {}\n\n bootstrap() {\n this.server.start();\n }\n}\n"; };
exports.appStarterCode = appStarterCode;