@basementscripts/require-headers-middleware
v1.0.0
Published
Require Headers Middleware for Express.js
Downloads
1
Keywords
Readme
@basementscripts/require-headers-middleware
Install
yarn add @basementscripts/require-headers-middleware
Usage
import requireHeaders from '@basementscripts/require-headers-middleware'
import express, { Router} from 'express'
const router: Router = express.Router()
router.post('/complete-upload',
requireHeaders(
'x-amz-sns-message-type',
'x-amz-sns-message-id',
'x-amz-sns-topic-arn'
)
)
export default router
Retrieve Validated Headers
In your express controller, use the getValidatedHeaders
request middleware method to retrieve the validated headers.
export default (req: any, res: any) => {
const validHeaders = req.getValidatedHeaders()
res.send(validHeaders)
}