From 6e1e8cdaf7c477caa572fd53968ca4d95b2760de Mon Sep 17 00:00:00 2001 From: alesancor1 Date: Mon, 13 Feb 2023 20:01:27 +0100 Subject: [PATCH] fix: Incorrect double negation in template Solves #11 --- templates/server/index.js.hbs | 4 +++- templates/server/server.js.hbs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/templates/server/index.js.hbs b/templates/server/index.js.hbs index e23911d..593a5dc 100644 --- a/templates/server/index.js.hbs +++ b/templates/server/index.js.hbs @@ -42,6 +42,7 @@ const app = express(); app.use(express.json({limit: '50mb'})); const config = { + {{~#if oasFile.components.securitySchemes~}} middleware: { security: { auth: { @@ -51,6 +52,7 @@ const config = { } } } + {{/if}} } {{#if options.installModule}}use({{options.installModule.moduleName}}){{/if}} @@ -58,7 +60,7 @@ initialize(app, config).then(() => { http.createServer(app).listen(serverPort, () => { console.log("\nApp running at http://localhost:" + serverPort); console.log("________________________________________________________________"); - if (config.middleware.swagger?.disable !== false) { + if (!config?.middleware?.swagger?.disable) { console.log('API docs (Swagger UI) available on http://localhost:' + serverPort + '/docs'); console.log("________________________________________________________________"); } diff --git a/templates/server/server.js.hbs b/templates/server/server.js.hbs index 107abe1..613f473 100644 --- a/templates/server/server.js.hbs +++ b/templates/server/server.js.hbs @@ -17,6 +17,7 @@ const deploy = async () => { app.use(express.json({limit: '50mb'})); const config = { + {{~#if oasFile.components.securitySchemes~}} middleware: { security: { auth: { @@ -26,6 +27,7 @@ const deploy = async () => { } } } + {{~/if~}} } {{#if options.installModule}}use({{options.installModule.moduleName}}){{/if}} @@ -33,7 +35,7 @@ const deploy = async () => { http.createServer(app).listen(serverPort, () => { console.log("\nApp running at http://localhost:" + serverPort); console.log("________________________________________________________________"); - if (config.middleware.swagger?.disable !== false) { + if (!config?.middleware?.swagger?.disable) { console.log('API docs (Swagger UI) available on http://localhost:' + serverPort + '/docs'); console.log("________________________________________________________________"); }