UNPKG

778 Btext/coffeescriptView Raw
1expressOctoblu = require 'express-octoblu'
2MeshbluAuth = require 'express-meshblu-auth'
3Router = require './router'
4multer = require 'multer'
5debug = require('debug')('triggers-service:server')
6
7class Server
8 constructor: (options)->
9 { @logFn, @disableLogging, @port } = options
10 { @meshbluConfig } = options
11
12 address: =>
13 @server.address()
14
15 run: (callback) =>
16 meshbluAuth = new MeshbluAuth @meshbluConfig
17
18 app = expressOctoblu({ @logFn, @disableLogging, bodyLimit: '50mb' })
19 app.use meshbluAuth.auth()
20 app.use multer().any()
21
22 router = new Router {@meshbluConfig, meshbluAuth}
23 router.route app
24
25 @server = app.listen @port, callback
26
27 stop: (callback) =>
28 @server.close callback
29
30module.exports = Server