Skip to content

Commit c809500

Browse files
JohanObrinkjoshski
authored andcommitted
Added support for middlewares and server.close
1 parent 4fcbe43 commit c809500

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/idp.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ function create (options) {
7878
app.use(express.static(`${process.cwd()}/public`))
7979
app.use(express.static(`${process.cwd()}/node_modules/purecss/build`))
8080

81+
if (Array.isArray(options.middlewares)) {
82+
options.middlewares.forEach(mw => app.use(mw))
83+
}
84+
8185
// Log in page / details
8286
app.get('/', (req, res) => {
8387
if (req.session && req.session.user) {
@@ -150,7 +154,8 @@ function create (options) {
150154
const _listen = app.listen.bind(app)
151155
app.listen = (port, cb) => {
152156
app.options = setOptions(extend(true, {port}, app.options))
153-
return _listen(port, cb)
157+
const server = _listen(port, cb)
158+
return Object.assign(app, {server})
154159
}
155160

156161
return app

0 commit comments

Comments
 (0)