Passed
Push — master ( 2f9144...7e7ad0 )
by Vinicius
02:23
created

index.js (1 issue)

1
'use strict'
2
3
const path = require('path')
4
5
const renderFactory = (options, res, next) => {
0 ignored issues
show
The parameter next is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
6
  const callback = (err, html) => {
7
    if (err) {
8
      throw err
9
    }
10
    res.setHeader('Content-Type', 'text/html')
11
    res.writeHead(200)
12
    res.end(html)
13
  }
14
  return function (view, state = {}, userCallback) {
15
    options.engine(path.join(options.dir, view), state, userCallback || callback)
16
  }
17
}
18
19
const middlewareFactory = (options) => {
20
  return function (req, res, next) {
21
    res.render = renderFactory(options, res, next)
22
    next()
23
  }
24
}
25
26
module.exports = middlewareFactory
27