1.0.0 • Published 4 years ago

@speedup/micro-guard-method v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

SpeedUP method guard for microservices

This module enables the method check for zeit/micro package.

NPM version NPM downloads

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