-
Notifications
You must be signed in to change notification settings - Fork 3
Middleware
Björn Schmidtke edited this page May 19, 2017
·
2 revisions
Penguin.js makes it easy to include your own middleware.
penguin run
and penguin serve
accept an argument like --middleware [ ./custom ]
.
Penguin.js excpects that the middleware exports a express middleware.
Notice: If you include multiple middlewares, the order of the middlewares will be the same as the order of the arguments passed to penguin! Example: Let's say you have two middlewares that you include like that:
penguin run --middleware [ ./custom ] --middleware [ penguin-passwordless ...]
//custom.js
'use strict'
const { Router } = require('express')
const request = require('request')
const noCache = require('nocache')
module.exports = () => {
const router = Router()
router.get('/custom', noCache(), (req, res) => {
res.send(`Hello World`)
})
return router
}