micro-handlers
Version:
Different handlers based on HTTP method for Micro
59 lines (37 loc) • 991 B
Markdown
# micro-handlers
> Different handlers based on HTTP method for Micro

[](https://npmjs.com/micro-handlers)
[](https://packagephobia.com/result?p=micro-handlers)
## Install
```sh
npm install micro-handlers
```
or
```sh
yarn add micro-handlers
```
## Usage
```js
const microHandlers = require('micro-handlers')
module.exports = microHandlers({
GET: (req, res) => {
res.end('Hello from GET')
},
POST: (req, res) => {
res.end('Hello from POST')
},
})
```
## API
### microHandlers(handlers)
#### handlers
Type: `Record<Method, Handler>`
##### Method
Type: `GET | POST | PUT | PATCH | DELETE`
##### Handler
Type: `Function`
## License
[MIT](./license)
## Related
- [`allowed-methods`](https://github.com/acestojanoski/allowed-methods)