@speedup/micro-guard-method
v1.0.0
Published
Method guard for zeit/micro compatible services
Downloads
21
Maintainers
Readme
SpeedUP method guard for microservices
This module enables the method check for zeit/micro package.
Installation
# NPM
npm i @speedup/micro-guard-method --save
# Yarn
yarn install @speedup/micro-guard-method
Usage
const micro = require('micro');
const MethodGuard = require('@speedup/micro-guard-method');
const methodGuard = MethodGuard('GET');
// or
const methodGuard = MethodGuard(['GET', 'POST']);
module.exports = async (req, res) => {
try {
methodGuard(req);
// do whatever you want
// ...
}
catch(err) {
// catch the error here
}
};
And you're good to go!
License
MIT