Different handlers based on HTTP method for Micro
npm install micro-handlers
or
yarn add micro-handlers
const microHandlers = require('micro-handlers')
module.exports = microHandlers({
GET: (req, res) => {
res.end('Hello from GET')
},
POST: (req, res) => {
res.end('Hello from POST')
},
})
Type: Record<Method, Handler>
Type: GET | POST | PUT | PATCH | DELETE
Type: Function