From 22bc5df12c3603b375e2def30f48c0f73d947363 Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Wed, 5 Jul 2017 12:49:26 +0100 Subject: [PATCH] default-stack module --- lib/command/middleware-list.js | 17 +---------------- lib/command/serve.js | 17 +---------------- lib/default-stack.js | 16 ++++++++++++++++ lib/local-web-server.js | 17 +---------------- package.json | 2 +- 5 files changed, 20 insertions(+), 49 deletions(-) create mode 100644 lib/default-stack.js diff --git a/lib/command/middleware-list.js b/lib/command/middleware-list.js index ed622a6..557efc4 100644 --- a/lib/command/middleware-list.js +++ b/lib/command/middleware-list.js @@ -3,22 +3,7 @@ class MiddlewareList { return 'Print available middleware' } execute (options) { - const list = [ - 'lws-request-monitor', - 'lws-log', - 'lws-cors', - 'lws-json', - 'lws-rewrite', - 'lws-body-parser', - 'lws-blacklist', - 'lws-conditional-get', - 'lws-mime', - 'lws-compress', - 'lws-mock-response', - 'lws-spa', - 'lws-static', - 'lws-index' - ] + const list = require('../default-stack') console.log(list) } } diff --git a/lib/command/serve.js b/lib/command/serve.js index d81d2d7..b66c189 100644 --- a/lib/command/serve.js +++ b/lib/command/serve.js @@ -13,22 +13,7 @@ class WsServe extends ServeCommand { .set('av', require('../../package').version) .set('cd4', 'cli') options = { - stack: [ - 'lws-request-monitor', - 'lws-log', - 'lws-cors', - 'lws-json', - 'lws-rewrite', - 'lws-body-parser', - 'lws-blacklist', - 'lws-conditional-get', - 'lws-mime', - 'lws-compress', - 'lws-mock-response', - 'lws-spa', - 'lws-static', - 'lws-index' - ], + stack: require('../default-stack'), moduleDir: path.resolve(__dirname, `../../node_modules`), modulePrefix: 'lws-' } diff --git a/lib/default-stack.js b/lib/default-stack.js new file mode 100644 index 0000000..7d2082f --- /dev/null +++ b/lib/default-stack.js @@ -0,0 +1,16 @@ +module.exports = [ + 'lws-body-parser', + 'lws-request-monitor', + 'lws-log', + 'lws-cors', + 'lws-json', + 'lws-rewrite', + 'lws-blacklist', + 'lws-conditional-get', + 'lws-mime', + 'lws-compress', + 'lws-mock-response', + 'lws-spa', + 'lws-static', + 'lws-index' +] diff --git a/lib/local-web-server.js b/lib/local-web-server.js index 92ac13d..5455322 100644 --- a/lib/local-web-server.js +++ b/lib/local-web-server.js @@ -11,22 +11,7 @@ class LocalWebServer extends Lws { options = Object.assign({ moduleDir: path.resolve(__dirname, `../node_modules`), modulePrefix: 'lws-', - stack: [ - 'lws-request-monitor', - 'lws-log', - 'lws-cors', - 'lws-json', - 'lws-rewrite', - 'lws-body-parser', - 'lws-blacklist', - 'lws-conditional-get', - 'lws-mime', - 'lws-compress', - 'lws-mock-response', - 'lws-spa', - 'lws-static', - 'lws-index' - ] + stack: require('./default-stack') }, options) return super.create(options) } diff --git a/package.json b/package.json index 0367ca6..a7462d9 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "lws-json": "^0.3.2", "lws-log": "^0.3.0", "lws-mime": "^0.2.1", - "lws-mock-response": "^0.2.3", + "lws-mock-response": "^0.2.4", "lws-request-monitor": "^0.1.0", "lws-rewrite": "^0.3.4", "lws-spa": "^0.2.2",