From dade010be3accbc3551a82e64a1471f0681ba61c Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 4 Nov 2021 14:50:09 +0000 Subject: [PATCH 01/25] refactor: introducing swagger --- .../services/file-downloading/index.js | 7 +++++- .../services/file-uploading/index.js | 7 +++++- lib/components/services/server/index.js | 23 ++++++++++++++++++- lib/components/services/server/swagger.js | 19 +++++++++++++++ lib/components/services/statebox-api/index.js | 9 ++++---- .../services/statebox-api/swagger.js | 14 +++++++++++ package.json | 1 + 7 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 lib/components/services/server/swagger.js create mode 100644 lib/components/services/statebox-api/swagger.js diff --git a/lib/components/services/file-downloading/index.js b/lib/components/services/file-downloading/index.js index afa740fe..307e6d36 100644 --- a/lib/components/services/file-downloading/index.js +++ b/lib/components/services/file-downloading/index.js @@ -13,7 +13,12 @@ class FileDownloadingService { const { app } = server const router = async app => { - app.get('/:downloadKey', (request, reply) => this.serveFile(request, reply)) + const opts = { + schema: { + description: 'Download a file' + } + } + app.get('/:downloadKey', opts, (request, reply) => this.serveFile(request, reply)) } app.register(router, { prefix: downloadPrefix }) diff --git a/lib/components/services/file-uploading/index.js b/lib/components/services/file-uploading/index.js index 88d2878c..fe4b2c01 100644 --- a/lib/components/services/file-uploading/index.js +++ b/lib/components/services/file-uploading/index.js @@ -11,7 +11,12 @@ class FileUploadingService { const { app } = server const router = async app => { - const opts = { preValidation: [app.jwtCheck] } + const opts = { + preValidation: [app.jwtCheck], + schema: { + description: 'Upload a file' + } + } app.post('/', opts, (request, reply) => this.upload(request, reply)) } diff --git a/lib/components/services/server/index.js b/lib/components/services/server/index.js index 7873dac3..d4024bb3 100644 --- a/lib/components/services/server/index.js +++ b/lib/components/services/server/index.js @@ -2,8 +2,10 @@ const fastify = require('fastify') const helmet = require('fastify-helmet') const cors = require('fastify-cors') const multipart = require('fastify-multipart') +const swagger = require('fastify-swagger') const debug = require('debug')('tymly-fastify-plugin') +const swaggerOpts = require('./swagger') const addStaticDir = require('./add-static-dir') class FastifyServerService { @@ -17,7 +19,22 @@ class FastifyServerService { const app = fastify() - app.register(helmet) + app.register(swagger, swaggerOpts) + app.register(helmet, instance => { + return { + contentSecurityPolicy: { + directives: { + ...helmet.contentSecurityPolicy.getDefaultDirectives(), + 'form-action': ["'self'"], + 'img-src': ["'self'", 'data:', 'validator.swagger.io'], + 'script-src': ["'self'"].concat(instance.swaggerCSP.script), + 'style-src': ["'self'", 'https:'].concat( + instance.swaggerCSP.style + ) + } + } + } + }) app.register(multipart) app.addContentTypeParser( @@ -75,6 +92,10 @@ class FastifyServerService { this.app.listen(port, host, callback) } + swagger () { + this.app.swagger() + } + /** * Invokes shutdown function on this.app * @example diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js new file mode 100644 index 00000000..80eea24c --- /dev/null +++ b/lib/components/services/server/swagger.js @@ -0,0 +1,19 @@ +module.exports = { + routePrefix: '/documentation', + exposeRoute: true, + // staticCSP: true, + swagger: { + info: { + title: 'Tymly API', + description: 'Provides a CORS-enabled Fastify server' + }, + externalDocs: { + url: 'https://swagger.io', + description: 'Find more info here' + }, + host: 'localhost:3210', + schemes: ['https'], + consumes: ['application/json'], + produces: ['application/json'] + } +} diff --git a/lib/components/services/statebox-api/index.js b/lib/components/services/statebox-api/index.js index 81cee615..d80313fc 100644 --- a/lib/components/services/statebox-api/index.js +++ b/lib/components/services/statebox-api/index.js @@ -1,4 +1,5 @@ const routes = require('./routes/index') +const swagger = require('./swagger') class StateboxApiService { boot (options) { @@ -7,10 +8,10 @@ class StateboxApiService { const router = async app => { const opts = { preValidation: [app.jwtCheck] } - app.post('/', opts, routes.startExecution) - app.get('/:executionName', opts, routes.describeExecution) - app.put('/:executionName', opts, routes.executionAction) - app.delete('/:executionName', opts, routes.stopExecution) + app.post('/', { ...opts, schema: swagger.startExecution }, routes.startExecution) + app.get('/:executionName', { ...opts, schema: swagger.describeExecution }, routes.describeExecution) + app.put('/:executionName', { ...opts, schema: swagger.executionAction }, routes.executionAction) + app.delete('/:executionName', { ...opts, schema: swagger.stopExecution }, routes.stopExecution) } app.register(router, { prefix: '/executions' }) diff --git a/lib/components/services/statebox-api/swagger.js b/lib/components/services/statebox-api/swagger.js new file mode 100644 index 00000000..7a4c9243 --- /dev/null +++ b/lib/components/services/statebox-api/swagger.js @@ -0,0 +1,14 @@ +module.exports = { + startExecution: { + description: 'Start a new statebox execution' + }, + describeExecution: { + description: 'Describe an existing statebox execution' + }, + executionAction: { + description: 'Perform an action on an existing statebox execution' + }, + stopExecution: { + description: 'Stop an existing statebox execution' + } +} diff --git a/package.json b/package.json index 46b6c65e..aa78d74c 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "fastify-jwt": "3.0.1", "fastify-multipart": "4.0.7", "fastify-static": "4.4.1", + "fastify-swagger": "4.12.6", "jsonwebtoken": "8.5.1", "lodash": "4.17.21", "uuid": "8.3.2" From 7259828ac083fcf16f3a40aa9394408be86309b9 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 4 Nov 2021 15:29:27 +0000 Subject: [PATCH 02/25] feat: add swagger details about statebox-api --- lib/components/services/server/swagger.js | 2 +- .../services/statebox-api/swagger.js | 67 +++++++++++++++++-- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index 80eea24c..2ce6a5b2 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -11,7 +11,7 @@ module.exports = { url: 'https://swagger.io', description: 'Find more info here' }, - host: 'localhost:3210', + // host: 'localhost', schemes: ['https'], consumes: ['application/json'], produces: ['application/json'] diff --git a/lib/components/services/statebox-api/swagger.js b/lib/components/services/statebox-api/swagger.js index 7a4c9243..e1296e04 100644 --- a/lib/components/services/statebox-api/swagger.js +++ b/lib/components/services/statebox-api/swagger.js @@ -1,14 +1,73 @@ module.exports = { startExecution: { - description: 'Start a new statebox execution' + description: 'Start a new Statebox execution', + body: { + type: 'object', + properties: { + stateMachineName: { + type: 'string', + description: 'State machine name' + }, + input: { + type: 'object', + description: 'Input' + }, + options: { + type: 'object', + description: 'Options' + } + } + } }, describeExecution: { - description: 'Describe an existing statebox execution' + description: 'Describe an existing Statebox execution', + params: { + type: 'object', + properties: { + executionName: { + type: 'string', + description: 'Execution name' + } + } + } }, executionAction: { - description: 'Perform an action on an existing statebox execution' + description: 'Perform an action on an existing Statebox execution', + params: { + type: 'object', + properties: { + executionName: { + type: 'string', + description: 'Execution name' + } + } + }, + body: { + type: 'object', + properties: { + action: { + type: 'string', + description: 'Action to perform on Statebox execution', + enum: [ + 'SendTaskSuccess', + 'SendTaskHeartbeat', + 'SendTaskRevivification', + 'WaitUntilStoppedRunning' + ] + } + } + } }, stopExecution: { - description: 'Stop an existing statebox execution' + description: 'Stop an existing Statebox execution', + params: { + type: 'object', + properties: { + executionName: { + type: 'string', + description: 'Execution name' + } + } + } } } From 2de296276db741d995280b8b8d39c4e7eb78f7af Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 4 Nov 2021 15:35:20 +0000 Subject: [PATCH 03/25] feat: file downloading swagger schema --- lib/components/services/file-downloading/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/components/services/file-downloading/index.js b/lib/components/services/file-downloading/index.js index 307e6d36..a916fabe 100644 --- a/lib/components/services/file-downloading/index.js +++ b/lib/components/services/file-downloading/index.js @@ -15,7 +15,16 @@ class FileDownloadingService { const router = async app => { const opts = { schema: { - description: 'Download a file' + description: 'Download a file', + params: { + type: 'object', + properties: { + downloadKey: { + type: 'string', + description: 'Download key' + } + } + } } } app.get('/:downloadKey', opts, (request, reply) => this.serveFile(request, reply)) From 57065684be020ea01b0e39b0887630dd0f2b9f5a Mon Sep 17 00:00:00 2001 From: meenahoda Date: Fri, 5 Nov 2021 11:59:14 +0000 Subject: [PATCH 04/25] feat: add tags to swagger docs --- lib/components/services/statebox-api/swagger.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/components/services/statebox-api/swagger.js b/lib/components/services/statebox-api/swagger.js index e1296e04..65517a4f 100644 --- a/lib/components/services/statebox-api/swagger.js +++ b/lib/components/services/statebox-api/swagger.js @@ -1,5 +1,8 @@ +const tags = ['executions'] + module.exports = { startExecution: { + tags, description: 'Start a new Statebox execution', body: { type: 'object', @@ -20,6 +23,7 @@ module.exports = { } }, describeExecution: { + tags, description: 'Describe an existing Statebox execution', params: { type: 'object', @@ -32,6 +36,7 @@ module.exports = { } }, executionAction: { + tags, description: 'Perform an action on an existing Statebox execution', params: { type: 'object', @@ -59,6 +64,7 @@ module.exports = { } }, stopExecution: { + tags, description: 'Stop an existing Statebox execution', params: { type: 'object', From 61746a1b61a15de01c7e802242a0dfb91ec50632 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Fri, 5 Nov 2021 12:19:22 +0000 Subject: [PATCH 05/25] refactor: route schemas --- lib/components/services/server/index.js | 17 +--- lib/components/services/server/swagger.js | 18 ++++- lib/components/services/statebox-api/index.js | 9 +-- .../statebox-api/routes/common-schema.js | 5 ++ .../statebox-api/routes/describe-execution.js | 18 ++++- .../statebox-api/routes/execution-action.js | 33 +++++++- .../statebox-api/routes/start-execution.js | 29 ++++++- .../statebox-api/routes/stop-execution.js | 18 ++++- .../services/statebox-api/swagger.js | 79 ------------------- 9 files changed, 117 insertions(+), 109 deletions(-) create mode 100644 lib/components/services/statebox-api/routes/common-schema.js delete mode 100644 lib/components/services/statebox-api/swagger.js diff --git a/lib/components/services/server/index.js b/lib/components/services/server/index.js index d4024bb3..979b629a 100644 --- a/lib/components/services/server/index.js +++ b/lib/components/services/server/index.js @@ -5,6 +5,7 @@ const multipart = require('fastify-multipart') const swagger = require('fastify-swagger') const debug = require('debug')('tymly-fastify-plugin') + const swaggerOpts = require('./swagger') const addStaticDir = require('./add-static-dir') @@ -20,21 +21,7 @@ class FastifyServerService { const app = fastify() app.register(swagger, swaggerOpts) - app.register(helmet, instance => { - return { - contentSecurityPolicy: { - directives: { - ...helmet.contentSecurityPolicy.getDefaultDirectives(), - 'form-action': ["'self'"], - 'img-src': ["'self'", 'data:', 'validator.swagger.io'], - 'script-src': ["'self'"].concat(instance.swaggerCSP.script), - 'style-src': ["'self'", 'https:'].concat( - instance.swaggerCSP.style - ) - } - } - } - }) + app.register(helmet) app.register(multipart) app.addContentTypeParser( diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index 2ce6a5b2..1f0a8582 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -1,7 +1,7 @@ module.exports = { routePrefix: '/documentation', exposeRoute: true, - // staticCSP: true, + staticCSP: true, swagger: { info: { title: 'Tymly API', @@ -11,9 +11,21 @@ module.exports = { url: 'https://swagger.io', description: 'Find more info here' }, - // host: 'localhost', - schemes: ['https'], + host: '0.0.0.0', + schemes: ['http', 'https'], consumes: ['application/json'], produces: ['application/json'] + // securityDefinitions: { + // Bearer: { + // type: 'apiKey', + // name: 'Authorization', + // in: 'header' + // } + // }, + // security: [ + // { + // Bearer: [] + // } + // ] } } diff --git a/lib/components/services/statebox-api/index.js b/lib/components/services/statebox-api/index.js index d80313fc..a5dbdd4a 100644 --- a/lib/components/services/statebox-api/index.js +++ b/lib/components/services/statebox-api/index.js @@ -1,5 +1,4 @@ const routes = require('./routes/index') -const swagger = require('./swagger') class StateboxApiService { boot (options) { @@ -8,10 +7,10 @@ class StateboxApiService { const router = async app => { const opts = { preValidation: [app.jwtCheck] } - app.post('/', { ...opts, schema: swagger.startExecution }, routes.startExecution) - app.get('/:executionName', { ...opts, schema: swagger.describeExecution }, routes.describeExecution) - app.put('/:executionName', { ...opts, schema: swagger.executionAction }, routes.executionAction) - app.delete('/:executionName', { ...opts, schema: swagger.stopExecution }, routes.stopExecution) + app.post('/', { ...opts, schema: routes.startExecution.schema }, routes.startExecution) + app.get('/:executionName', { ...opts, schema: routes.describeExecution.schema }, routes.describeExecution) + app.put('/:executionName', { ...opts, schema: routes.executionAction.schema }, routes.executionAction) + app.delete('/:executionName', { ...opts, schema: routes.stopExecution.schema }, routes.stopExecution) } app.register(router, { prefix: '/executions' }) diff --git a/lib/components/services/statebox-api/routes/common-schema.js b/lib/components/services/statebox-api/routes/common-schema.js new file mode 100644 index 00000000..0b9611f9 --- /dev/null +++ b/lib/components/services/statebox-api/routes/common-schema.js @@ -0,0 +1,5 @@ +const schema = { + tags: ['executions'] +} + +module.exports = schema diff --git a/lib/components/services/statebox-api/routes/describe-execution.js b/lib/components/services/statebox-api/routes/describe-execution.js index 5e9f2725..b1726adb 100644 --- a/lib/components/services/statebox-api/routes/describe-execution.js +++ b/lib/components/services/statebox-api/routes/describe-execution.js @@ -1,7 +1,20 @@ const respond = require('../../../../util/respond') const debug = require('debug')('tymly-fastify-plugin') +const schema = { + ...require('./common-schema'), + description: 'Describe an existing Statebox execution', + params: { + type: 'object', + properties: { + executionName: { + type: 'string', + description: 'Execution name' + } + } + } +} -module.exports = function describeExecution (request, reply) { +function describeExecution (request, reply) { const jwtAuthService = this.services.jwtAuth const statebox = this.services.statebox @@ -28,3 +41,6 @@ module.exports = function describeExecution (request, reply) { } ) } + +module.exports = describeExecution +module.exports.schema = schema diff --git a/lib/components/services/statebox-api/routes/execution-action.js b/lib/components/services/statebox-api/routes/execution-action.js index ced8e34c..0d522505 100644 --- a/lib/components/services/statebox-api/routes/execution-action.js +++ b/lib/components/services/statebox-api/routes/execution-action.js @@ -1,8 +1,36 @@ const { cloneDeep } = require('lodash') const boom = require('@hapi/boom') const actions = require('../actions/index') +const schema = { + ...require('./common-schema'), + description: 'Perform an action on an existing Statebox execution', + params: { + type: 'object', + properties: { + executionName: { + type: 'string', + description: 'Execution name' + } + } + }, + body: { + type: 'object', + properties: { + action: { + type: 'string', + description: 'Action to perform on Statebox execution', + enum: [ + 'SendTaskSuccess', + 'SendTaskHeartbeat', + 'SendTaskRevivification', + 'WaitUntilStoppedRunning' + ] + } + } + } +} -module.exports = function (request, reply) { +function executionAction (request, reply) { const jwtAuthService = this.services.jwtAuth const statebox = this.services.statebox @@ -28,3 +56,6 @@ module.exports = function (request, reply) { ) } } + +module.exports = executionAction +module.exports.schema = schema diff --git a/lib/components/services/statebox-api/routes/start-execution.js b/lib/components/services/statebox-api/routes/start-execution.js index aca430a8..63cdef27 100644 --- a/lib/components/services/statebox-api/routes/start-execution.js +++ b/lib/components/services/statebox-api/routes/start-execution.js @@ -1,8 +1,30 @@ const { cloneDeep } = require('lodash') const respond = require('../../../../util/respond') const debug = require('debug')('tymly-fastify-plugin') +const cloneOrDefault = obj => obj ? cloneDeep(obj) : {} +const schema = { + ...require('./common-schema'), + description: 'Start a new Statebox execution', + body: { + type: 'object', + properties: { + stateMachineName: { + type: 'string', + description: 'State machine name' + }, + input: { + type: 'object', + description: 'Input' + }, + options: { + type: 'object', + description: 'Options' + } + } + } +} -module.exports = function startExecution (request, reply) { +function startExecution (request, reply) { const jwtAuthService = this.services.jwtAuth const statebox = this.services.statebox @@ -29,6 +51,5 @@ module.exports = function startExecution (request, reply) { ) } -function cloneOrDefault (obj) { - return obj ? cloneDeep(obj) : {} -} +module.exports = startExecution +module.exports.schema = schema diff --git a/lib/components/services/statebox-api/routes/stop-execution.js b/lib/components/services/statebox-api/routes/stop-execution.js index 5a08aa60..eacb252b 100644 --- a/lib/components/services/statebox-api/routes/stop-execution.js +++ b/lib/components/services/statebox-api/routes/stop-execution.js @@ -1,7 +1,20 @@ const respond = require('../../../../util/respond') const debug = require('debug')('tymly-fastify-plugin') +const schema = { + ...require('./common-schema'), + description: 'Stop an existing Statebox execution', + params: { + type: 'object', + properties: { + executionName: { + type: 'string', + description: 'Execution name' + } + } + } +} -module.exports = function cancelTymlyRoute (request, reply) { +function stopExecution (request, reply) { const jwtAuthService = this.services.jwtAuth const statebox = this.services.statebox @@ -26,3 +39,6 @@ module.exports = function cancelTymlyRoute (request, reply) { } ) } + +module.exports = stopExecution +module.exports.schema = schema diff --git a/lib/components/services/statebox-api/swagger.js b/lib/components/services/statebox-api/swagger.js deleted file mode 100644 index 65517a4f..00000000 --- a/lib/components/services/statebox-api/swagger.js +++ /dev/null @@ -1,79 +0,0 @@ -const tags = ['executions'] - -module.exports = { - startExecution: { - tags, - description: 'Start a new Statebox execution', - body: { - type: 'object', - properties: { - stateMachineName: { - type: 'string', - description: 'State machine name' - }, - input: { - type: 'object', - description: 'Input' - }, - options: { - type: 'object', - description: 'Options' - } - } - } - }, - describeExecution: { - tags, - description: 'Describe an existing Statebox execution', - params: { - type: 'object', - properties: { - executionName: { - type: 'string', - description: 'Execution name' - } - } - } - }, - executionAction: { - tags, - description: 'Perform an action on an existing Statebox execution', - params: { - type: 'object', - properties: { - executionName: { - type: 'string', - description: 'Execution name' - } - } - }, - body: { - type: 'object', - properties: { - action: { - type: 'string', - description: 'Action to perform on Statebox execution', - enum: [ - 'SendTaskSuccess', - 'SendTaskHeartbeat', - 'SendTaskRevivification', - 'WaitUntilStoppedRunning' - ] - } - } - } - }, - stopExecution: { - tags, - description: 'Stop an existing Statebox execution', - params: { - type: 'object', - properties: { - executionName: { - type: 'string', - description: 'Execution name' - } - } - } - } -} From ffcf2a8fda5c310d22c3a460d68e3dd6848b4afa Mon Sep 17 00:00:00 2001 From: meenahoda Date: Fri, 5 Nov 2021 12:30:11 +0000 Subject: [PATCH 06/25] feat: extract common schema out and authorize --- lib/components/services/server/swagger.js | 26 +++++++++---------- .../statebox-api/routes/common-schema.js | 5 ++++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index 1f0a8582..8909b0fa 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -14,18 +14,18 @@ module.exports = { host: '0.0.0.0', schemes: ['http', 'https'], consumes: ['application/json'], - produces: ['application/json'] - // securityDefinitions: { - // Bearer: { - // type: 'apiKey', - // name: 'Authorization', - // in: 'header' - // } - // }, - // security: [ - // { - // Bearer: [] - // } - // ] + produces: ['application/json'], + securityDefinitions: { + Bearer: { + type: 'apiKey', + name: 'Authorization', + in: 'header' + } + }, + security: [ + { + Bearer: [] + } + ] } } diff --git a/lib/components/services/statebox-api/routes/common-schema.js b/lib/components/services/statebox-api/routes/common-schema.js index 0b9611f9..fe642bf6 100644 --- a/lib/components/services/statebox-api/routes/common-schema.js +++ b/lib/components/services/statebox-api/routes/common-schema.js @@ -1,5 +1,10 @@ const schema = { tags: ['executions'] + // security: [ + // { + // Bearer: [] + // } + // ] } module.exports = schema From c260b150165d31f5a98aa227d6b6404a42b51f26 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 11 Nov 2021 10:53:00 +0000 Subject: [PATCH 07/25] feat: extend start execution schema and comment out some swagger options --- lib/components/services/server/swagger.js | 10 ++++---- .../statebox-api/routes/start-execution.js | 23 +++++++++++++++---- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index 8909b0fa..2a92ccd3 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -7,12 +7,12 @@ module.exports = { title: 'Tymly API', description: 'Provides a CORS-enabled Fastify server' }, - externalDocs: { - url: 'https://swagger.io', - description: 'Find more info here' - }, + // externalDocs: { + // url: 'https://swagger.io', + // description: 'Find more info here' + // }, host: '0.0.0.0', - schemes: ['http', 'https'], + // schemes: ['http', 'https'], consumes: ['application/json'], produces: ['application/json'], securityDefinitions: { diff --git a/lib/components/services/statebox-api/routes/start-execution.js b/lib/components/services/statebox-api/routes/start-execution.js index 63cdef27..0a33b33c 100644 --- a/lib/components/services/statebox-api/routes/start-execution.js +++ b/lib/components/services/statebox-api/routes/start-execution.js @@ -9,16 +9,29 @@ const schema = { type: 'object', properties: { stateMachineName: { - type: 'string', - description: 'State machine name' + type: 'string' }, input: { - type: 'object', - description: 'Input' + type: 'object' }, options: { type: 'object', - description: 'Options' + properties: { + instigatingClient: { + type: 'object', + properties: { + appName: { + type: 'string' + }, + domain: { + type: 'string' + } + } + }, + sendResponse: { + type: 'string' + } + } } } } From 5587c9de981cb40301d9953d3860fde38bc5d8c2 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 11 Nov 2021 11:12:50 +0000 Subject: [PATCH 08/25] feat: integrate swagger with helmet --- lib/components/services/server/index.js | 16 +++++++++++++++- lib/components/services/server/swagger.js | 6 +----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/components/services/server/index.js b/lib/components/services/server/index.js index 979b629a..bb56f37b 100644 --- a/lib/components/services/server/index.js +++ b/lib/components/services/server/index.js @@ -21,7 +21,21 @@ class FastifyServerService { const app = fastify() app.register(swagger, swaggerOpts) - app.register(helmet) + app.register(helmet, instance => { + return { + contentSecurityPolicy: { + directives: { + ...helmet.contentSecurityPolicy.getDefaultDirectives(), + 'form-action': ["'self'"], + 'img-src': ["'self'", 'data:', 'validator.swagger.io'], + 'script-src': ["'self'"].concat(instance.swaggerCSP.script), + 'style-src': ["'self'", 'https:'].concat( + instance.swaggerCSP.style + ) + } + } + } + }) app.register(multipart) app.addContentTypeParser( diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index 2a92ccd3..863e12a5 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -1,16 +1,12 @@ module.exports = { routePrefix: '/documentation', exposeRoute: true, - staticCSP: true, + // staticCSP: true, swagger: { info: { title: 'Tymly API', description: 'Provides a CORS-enabled Fastify server' }, - // externalDocs: { - // url: 'https://swagger.io', - // description: 'Find more info here' - // }, host: '0.0.0.0', // schemes: ['http', 'https'], consumes: ['application/json'], From 05bb0e4bd252ddbe7bc35df51adde6844d2bbd3d Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 11 Nov 2021 11:28:54 +0000 Subject: [PATCH 09/25] fix: try staticCSP as well --- lib/components/services/server/swagger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index 863e12a5..fc0ccaf9 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -1,7 +1,7 @@ module.exports = { routePrefix: '/documentation', exposeRoute: true, - // staticCSP: true, + staticCSP: true, swagger: { info: { title: 'Tymly API', From e6fbfc17424e853e4558b21f24ee8f055b590bdb Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 11 Nov 2021 11:39:34 +0000 Subject: [PATCH 10/25] fix: uncomment schemes --- lib/components/services/server/swagger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index fc0ccaf9..79846c2d 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -8,7 +8,7 @@ module.exports = { description: 'Provides a CORS-enabled Fastify server' }, host: '0.0.0.0', - // schemes: ['http', 'https'], + schemes: ['http', 'https'], consumes: ['application/json'], produces: ['application/json'], securityDefinitions: { From f701a8ae02b9677e55a16be727f87763b6821e2f Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 11 Nov 2021 12:19:37 +0000 Subject: [PATCH 11/25] fix: standard style and revert some changes to swagger config --- lib/components/services/server/index.js | 9 +++++---- lib/components/services/server/swagger.js | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/components/services/server/index.js b/lib/components/services/server/index.js index bb56f37b..59fbca1e 100644 --- a/lib/components/services/server/index.js +++ b/lib/components/services/server/index.js @@ -21,15 +21,16 @@ class FastifyServerService { const app = fastify() app.register(swagger, swaggerOpts) + // app.register(helmet) app.register(helmet, instance => { return { contentSecurityPolicy: { directives: { ...helmet.contentSecurityPolicy.getDefaultDirectives(), - 'form-action': ["'self'"], - 'img-src': ["'self'", 'data:', 'validator.swagger.io'], - 'script-src': ["'self'"].concat(instance.swaggerCSP.script), - 'style-src': ["'self'", 'https:'].concat( + 'form-action': ['\'self\''], + 'img-src': ['\'self\'', 'data:', 'validator.swagger.io'], + 'script-src': ['\'self\''].concat(instance.swaggerCSP.script), + 'style-src': ['\'self\'', 'https:'].concat( instance.swaggerCSP.style ) } diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index 79846c2d..cf607c19 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -1,14 +1,14 @@ module.exports = { routePrefix: '/documentation', exposeRoute: true, - staticCSP: true, + // staticCSP: true, swagger: { info: { title: 'Tymly API', description: 'Provides a CORS-enabled Fastify server' }, - host: '0.0.0.0', - schemes: ['http', 'https'], + // host: '0.0.0.0', + // schemes: ['http', 'https'], consumes: ['application/json'], produces: ['application/json'], securityDefinitions: { @@ -23,5 +23,15 @@ module.exports = { Bearer: [] } ] + /* + security: [{ bearerAuth: [] }], + securityDefinitions: { + bearerAuth: { + type: "http", + scheme: "bearer", + bearerFormat: "JWT" + } + } + */ } } From 4a888119ef275e4662fd6cceb221ef00cd75f62c Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 11 Nov 2021 12:55:44 +0000 Subject: [PATCH 12/25] fix: swagger api can be called on listen --- lib/components/services/server/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/components/services/server/index.js b/lib/components/services/server/index.js index 59fbca1e..01bf4526 100644 --- a/lib/components/services/server/index.js +++ b/lib/components/services/server/index.js @@ -91,11 +91,10 @@ class FastifyServerService { ) */ listen (port, host, callback) { - this.app.listen(port, host, callback) - } - - swagger () { - this.app.swagger() + this.app.listen(port, host, () => { + this.app.swagger() + callback() + }) } /** From a7c64252dc4ef201d54fc83dd804a02da9a74c31 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 11 Nov 2021 13:17:34 +0000 Subject: [PATCH 13/25] fix: try adding port --- lib/components/services/server/swagger.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index cf607c19..f83bbfc4 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -2,12 +2,13 @@ module.exports = { routePrefix: '/documentation', exposeRoute: true, // staticCSP: true, + // uiConfig: {}, swagger: { info: { title: 'Tymly API', description: 'Provides a CORS-enabled Fastify server' }, - // host: '0.0.0.0', + host: '0.0.0.0:3210', // schemes: ['http', 'https'], consumes: ['application/json'], produces: ['application/json'], From b4b1c019f363b891fc068a9b3b1c3fccf3e0a9cf Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 11 Nov 2021 13:41:02 +0000 Subject: [PATCH 14/25] fix: remove host --- lib/components/services/server/swagger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index f83bbfc4..51caa142 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -8,7 +8,7 @@ module.exports = { title: 'Tymly API', description: 'Provides a CORS-enabled Fastify server' }, - host: '0.0.0.0:3210', + // host: '0.0.0.0', // schemes: ['http', 'https'], consumes: ['application/json'], produces: ['application/json'], From e0fcba47034c769cd243b625ff57d2a52903c6a2 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 11 Nov 2021 13:44:12 +0000 Subject: [PATCH 15/25] fix: force http scheme for dev --- lib/components/services/server/swagger.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index 51caa142..75bcb18c 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -10,6 +10,7 @@ module.exports = { }, // host: '0.0.0.0', // schemes: ['http', 'https'], + schemes: ['http'], consumes: ['application/json'], produces: ['application/json'], securityDefinitions: { From e7d32136e255570b40458c1cad47a109d206bbc5 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 11 Nov 2021 14:10:58 +0000 Subject: [PATCH 16/25] fix: remove schemes --- lib/components/services/server/swagger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index 75bcb18c..a2cd62a1 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -10,7 +10,7 @@ module.exports = { }, // host: '0.0.0.0', // schemes: ['http', 'https'], - schemes: ['http'], + // schemes: ['http'], consumes: ['application/json'], produces: ['application/json'], securityDefinitions: { From 67804d816fbe37f8b3afe88119078f5b4dd2d537 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Mon, 15 Nov 2021 09:44:04 +0000 Subject: [PATCH 17/25] fix: disable swagger ui validator --- lib/components/services/server/swagger.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index a2cd62a1..5383ea09 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -2,7 +2,9 @@ module.exports = { routePrefix: '/documentation', exposeRoute: true, // staticCSP: true, - // uiConfig: {}, + uiConfig: { + validatorUrl: null + }, swagger: { info: { title: 'Tymly API', From 61975fe45a2af2dc3bb218ba8bb71744cdbfd9f4 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Mon, 15 Nov 2021 11:13:57 +0000 Subject: [PATCH 18/25] fix(swagger): disable `try it out` --- lib/components/services/server/swagger.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index 5383ea09..af041378 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -3,7 +3,9 @@ module.exports = { exposeRoute: true, // staticCSP: true, uiConfig: { - validatorUrl: null + validatorUrl: null, + // tryItOutEnabled: false, + supportedSubmitMethods: [] }, swagger: { info: { From 38e494d3614a04a17a9a7be5cf1105b1d08a19bb Mon Sep 17 00:00:00 2001 From: meenahoda Date: Mon, 15 Nov 2021 11:14:50 +0000 Subject: [PATCH 19/25] fix(swagger): disable security definitions, as `try it out` is disabled --- lib/components/services/server/swagger.js | 42 +++++++++++------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index af041378..b07809e1 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -17,27 +17,25 @@ module.exports = { // schemes: ['http'], consumes: ['application/json'], produces: ['application/json'], - securityDefinitions: { - Bearer: { - type: 'apiKey', - name: 'Authorization', - in: 'header' - } - }, - security: [ - { - Bearer: [] - } - ] - /* - security: [{ bearerAuth: [] }], - securityDefinitions: { - bearerAuth: { - type: "http", - scheme: "bearer", - bearerFormat: "JWT" - } - } - */ + // securityDefinitions: { + // Bearer: { + // type: 'apiKey', + // name: 'Authorization', + // in: 'header' + // } + // }, + // security: [ + // { + // Bearer: [] + // } + // ] + // security: [{ bearerAuth: [] }], + // securityDefinitions: { + // bearerAuth: { + // type: "http", + // scheme: "bearer", + // bearerFormat: "JWT" + // } + // } } } From 772df9068fd55492be2ecf1ff611fc13361c2df6 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Mon, 15 Nov 2021 11:16:57 +0000 Subject: [PATCH 20/25] style: standard fix --- lib/components/services/server/swagger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index b07809e1..a93a5de0 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -16,7 +16,7 @@ module.exports = { // schemes: ['http', 'https'], // schemes: ['http'], consumes: ['application/json'], - produces: ['application/json'], + produces: ['application/json'] // securityDefinitions: { // Bearer: { // type: 'apiKey', From 1fb3e493e375bb0bc1418d5a6a3e56b411056d3b Mon Sep 17 00:00:00 2001 From: reecebrend Date: Wed, 25 Feb 2026 10:16:11 +0000 Subject: [PATCH 21/25] fix: remove ref to redundant debug --- lib/components/services/server/index.js | 1 - .../services/statebox-api/routes/describe-execution.js | 1 - lib/components/services/statebox-api/routes/start-execution.js | 1 - lib/components/services/statebox-api/routes/stop-execution.js | 1 - 4 files changed, 4 deletions(-) diff --git a/lib/components/services/server/index.js b/lib/components/services/server/index.js index 2973d66a..0a25566c 100644 --- a/lib/components/services/server/index.js +++ b/lib/components/services/server/index.js @@ -4,7 +4,6 @@ const multipart = require('fastify-multipart') const swagger = require('fastify-swagger') const swaggerOpts = require('./swagger') const helmet = require('@fastify/helmet') -const debug = require('debug')('tymly-fastify-plugin') const addStaticDir = require('./add-static-dir') diff --git a/lib/components/services/statebox-api/routes/describe-execution.js b/lib/components/services/statebox-api/routes/describe-execution.js index 862eb563..34a0b4d9 100644 --- a/lib/components/services/statebox-api/routes/describe-execution.js +++ b/lib/components/services/statebox-api/routes/describe-execution.js @@ -1,5 +1,4 @@ const respond = require('../../../../util/respond') -const debug = require('debug')('tymly-fastify-plugin') const schema = { ...require('./common-schema'), description: 'Describe an existing Statebox execution', diff --git a/lib/components/services/statebox-api/routes/start-execution.js b/lib/components/services/statebox-api/routes/start-execution.js index f341afa4..ba7dfd89 100644 --- a/lib/components/services/statebox-api/routes/start-execution.js +++ b/lib/components/services/statebox-api/routes/start-execution.js @@ -1,6 +1,5 @@ const { cloneDeep } = require('lodash') const respond = require('../../../../util/respond') -const debug = require('debug')('tymly-fastify-plugin') const cloneOrDefault = obj => obj ? cloneDeep(obj) : {} const schema = { diff --git a/lib/components/services/statebox-api/routes/stop-execution.js b/lib/components/services/statebox-api/routes/stop-execution.js index c5f3100b..fbe9c603 100644 --- a/lib/components/services/statebox-api/routes/stop-execution.js +++ b/lib/components/services/statebox-api/routes/stop-execution.js @@ -1,5 +1,4 @@ const respond = require('../../../../util/respond') -const debug = require('debug')('tymly-fastify-plugin') const schema = { ...require('./common-schema'), description: 'Stop an existing Statebox execution', From d82cb3d86d6645c682fb35e1ea9de5b40678e460 Mon Sep 17 00:00:00 2001 From: reecebrend Date: Wed, 25 Feb 2026 11:00:31 +0000 Subject: [PATCH 22/25] feat: update refactored fastify imports --- lib/components/services/server/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/components/services/server/index.js b/lib/components/services/server/index.js index 0a25566c..feb53945 100644 --- a/lib/components/services/server/index.js +++ b/lib/components/services/server/index.js @@ -1,7 +1,7 @@ const fastify = require('fastify') -const cors = require('fastify-cors') -const multipart = require('fastify-multipart') -const swagger = require('fastify-swagger') +const cors = require('@fastify/cors') +const multipart = require('@fastify/multipart') +const swagger = require('@fastify/swagger') const swaggerOpts = require('./swagger') const helmet = require('@fastify/helmet') From 80188fc393c5098b3a031a588b2c35e94bfa92d5 Mon Sep 17 00:00:00 2001 From: reecebrend Date: Wed, 25 Feb 2026 11:04:05 +0000 Subject: [PATCH 23/25] fix: update fastify swagger --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3a1a8204..c31b7a89 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "axios": "1.11.0", "@hapi/boom": "10.0.1", "cpr": "3.0.1", - "fastify-swagger": "4.12.6", + "@fastify/swagger": "6.0.0", "debug": "4.4.1", "dottie": "2.0.6", "fastify": "5.4.0", From db84176e13ee3e9758f0043f5da87f6abb66c555 Mon Sep 17 00:00:00 2001 From: reecebrend Date: Wed, 25 Feb 2026 13:05:14 +0000 Subject: [PATCH 24/25] fix: update swagger/fastify --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c31b7a89..ee389d0c 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "axios": "1.11.0", "@hapi/boom": "10.0.1", "cpr": "3.0.1", - "@fastify/swagger": "6.0.0", + "@fastify/swagger": "9.0.0", "debug": "4.4.1", "dottie": "2.0.6", "fastify": "5.4.0", From 9e313c958ec2c1ed1f3d35167d22ca51773e164c Mon Sep 17 00:00:00 2001 From: reecebrend Date: Wed, 25 Feb 2026 13:28:13 +0000 Subject: [PATCH 25/25] feat: update all swagger parts to new impl ensure tests pass --- lib/components/services/server/index.js | 53 ++++++++++++++--------- lib/components/services/server/swagger.js | 8 ---- package.json | 21 ++++----- test/download-spec.js | 6 +-- 4 files changed, 45 insertions(+), 43 deletions(-) diff --git a/lib/components/services/server/index.js b/lib/components/services/server/index.js index feb53945..8da71b9d 100644 --- a/lib/components/services/server/index.js +++ b/lib/components/services/server/index.js @@ -1,7 +1,7 @@ const fastify = require('fastify') const cors = require('@fastify/cors') -const multipart = require('@fastify/multipart') const swagger = require('@fastify/swagger') +const swaggerUi = require('@fastify/swagger-ui') const swaggerOpts = require('./swagger') const helmet = require('@fastify/helmet') @@ -23,25 +23,30 @@ class FastifyServerService { }) app.register(swagger, swaggerOpts) - // app.register(helmet) - app.register(helmet, instance => { - return { - contentSecurityPolicy: { - directives: { - ...helmet.contentSecurityPolicy.getDefaultDirectives(), - 'form-action': ['\'self\''], - 'img-src': ['\'self\'', 'data:', 'validator.swagger.io'], - 'script-src': ['\'self\''].concat(instance.swaggerCSP.script), - 'style-src': ['\'self\'', 'https:'].concat( - instance.swaggerCSP.style - ) - } - } + app.register(swaggerUi, { + routePrefix: '/documentation', + uiConfig: { + validatorUrl: null, + supportedSubmitMethods: [] } }) - app.register(multipart) - app.register(helmet, { - crossOriginResourcePolicy: { policy: 'cross-origin' } + app.after(() => { + app.register(helmet, instance => { + return { + contentSecurityPolicy: { + directives: { + ...helmet.contentSecurityPolicy.getDefaultDirectives(), + 'form-action': ['\'self\''], + 'img-src': ['\'self\'', 'data:', 'validator.swagger.io'], + 'script-src': ['\'self\''].concat(instance.swaggerCSP.script), + 'style-src': ['\'self\'', 'https:'].concat( + instance.swaggerCSP.style + ) + } + }, + crossOriginResourcePolicy: { policy: 'cross-origin' } + } + }) }) app.addContentTypeParser( @@ -96,9 +101,15 @@ class FastifyServerService { ) */ listen (port, host, callback) { - this.app.listen(port, host, () => { - this.app.swagger() - callback() + return new Promise((resolve, reject) => { + this.app.listen({ port, host }, (err) => { + if (err) { + if (callback) callback(err) + return reject(err) + } + if (callback) callback(null) + resolve() + }) }) } diff --git a/lib/components/services/server/swagger.js b/lib/components/services/server/swagger.js index a93a5de0..279ddcfd 100644 --- a/lib/components/services/server/swagger.js +++ b/lib/components/services/server/swagger.js @@ -1,12 +1,4 @@ module.exports = { - routePrefix: '/documentation', - exposeRoute: true, - // staticCSP: true, - uiConfig: { - validatorUrl: null, - // tryItOutEnabled: false, - supportedSubmitMethods: [] - }, swagger: { info: { title: 'Tymly API', diff --git a/package.json b/package.json index ee389d0c..cc01d16b 100644 --- a/package.json +++ b/package.json @@ -19,31 +19,32 @@ }, "main": "./lib/index.js", "dependencies": { - "axios": "1.11.0", - "@hapi/boom": "10.0.1", - "cpr": "3.0.1", - "@fastify/swagger": "9.0.0", - "debug": "4.4.1", - "dottie": "2.0.6", - "fastify": "5.4.0", "@fastify/cors": "11.0.1", "@fastify/helmet": "13.0.1", "@fastify/jwt": "9.1.0", "@fastify/multipart": "9.0.3", "@fastify/static": "8.2.0", + "@fastify/swagger": "9.0.0", + "@fastify/swagger-ui": "^5.2.5", + "@hapi/boom": "10.0.1", + "axios": "1.11.0", + "cpr": "3.0.1", + "debug": "4.4.1", + "dottie": "2.0.6", + "fastify": "5.4.0", "jsonwebtoken": "9.0.2", "lodash": "4.17.21", "uuid": "11.1.0" }, "devDependencies": { "@semantic-release/changelog": "6.0.3", - "@semantic-release/release-notes-generator": "14.1.0", - "@semantic-release/git": "10.0.1", "@semantic-release/exec": "7.1.0", + "@semantic-release/git": "10.0.1", + "@semantic-release/release-notes-generator": "14.1.0", "@wmfs/tymly": "1.315.0", + "@wmfs/tymly-cardscript-plugin": "1.51.0", "@wmfs/tymly-rbac-plugin": "1.32.0", "@wmfs/tymly-rest-client-plugin": "1.34.0", - "@wmfs/tymly-cardscript-plugin": "1.51.0", "chai": "4.5.0", "chai-string": "1.6.0", "codecov": "3.8.3", diff --git a/test/download-spec.js b/test/download-spec.js index d37ad870..42a3e351 100644 --- a/test/download-spec.js +++ b/test/download-spec.js @@ -44,10 +44,8 @@ describe('Download tests', function () { downloadService = tymlyServices.fileDownloading statebox = tymlyServices.statebox const server = tymlyServices.server - server.listen(PORT, HOST, (err) => { - expect(err).to.eql(null) - console.log(`Listening on ${PORT}`) - }) + await server.listen(PORT, HOST) + console.log(`Listening on ${PORT}`) }) describe('service tests', () => {