diff --git a/.eslintrc b/.eslintrc index 047272e06d..2c8ac6c0ac 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,6 +3,9 @@ "finn", "finn/node" ], + "parserOptions": { + "ecmaVersion": "2017" + }, "rules": { "max-nested-callbacks": "off" } diff --git a/lib/server-impl.js b/lib/server-impl.js index 500c5b8f1e..b251461fbc 100644 --- a/lib/server-impl.js +++ b/lib/server-impl.js @@ -15,15 +15,10 @@ function createApp (options) { const stores = createStores(options); const eventBus = new EventEmitter(); - const config = { - baseUriPath: options.baseUriPath, - serverMetrics: options.serverMetrics, - enableRequestLogger: options.enableRequestLogger, - port: options.port, - publicFolder: options.publicFolder, + const config = Object.assign({ stores, eventBus, - }; + }, options); const app = getApp(config); const server = app.listen(app.get('port'), () => { diff --git a/lib/server-impl.test.js b/lib/server-impl.test.js new file mode 100644 index 0000000000..0a295f2900 --- /dev/null +++ b/lib/server-impl.test.js @@ -0,0 +1,51 @@ +'use strict'; + +const test = require('ava'); +const proxyquire = require('proxyquire'); + +const getApp = proxyquire('./app', { + './routes': { + createAPI: () => {}, + createLegacy: () => {}, + }, +}); + +const serverImpl = proxyquire('./server-impl', { + './app': getApp, + './metrics': { + startMonitoring (o) { + return o; + }, + }, + './db': { + createStores (o) { + return o; + }, + }, + './options': { + createOptions (o) { + return o; + }, + }, + '../migrator' () { + return Promise.resolve(); + }, +}); + +test('should call preHook', async t => { + let called = 0; + await serverImpl.start({ + preHook: () => { + called++; + }, + }); + t.true(called === 1); +}); + +test('should call preRouterHook', async t => { + let called = 0; + await serverImpl.start({ preRouterHook: () => { + called++; + } }); + t.true(called === 1); +});