@speedup/micro-guard-method
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i @speedup/micro-guard-method

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

5.95 kB

Total Files

7

Last publish

Collaborators

  • dmanavi