🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

mali-error-mapper

Package Overview
Dependencies
Maintainers
9
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mali-error-mapper

Error mapper for Mali applications

latest
npmnpm
Version
2.0.0
Version published
Weekly downloads
5.3K
35.36%
Maintainers
9
Weekly downloads
 
Created
Source

Mali error mapper

Mali gRPC error mappers and middleware.

Middleware

This middleware maps all non GrpcError errors to a GrpcError formatted accordingly.

Status

Build Status

Installation

Install the package via yarn:

❯ yarn add mali-error-mapper

or via npm:

❯ npm install mali-error-mapper --save

Usage

Using default mapping:

'use strict';

const errorMapperMiddleware = require('mali-error-mapper');
const app = new Mali();

app.use(errorMapperMiddleware());

Using custom mappers:

'use strict';

const errorMapperMiddleware = require('mali-error-mapper');
const app = new Mali();
const mapper = {
  map: e => {
    if (!(e instanceof MyError)) {
      return;
    }

    return {
      body: {
        code: 'foo',
        message: 'bar'
      },
      status: 999
    };
  };
};

app.use(errorMiddleware([mapper]));

License

MIT

Keywords

error

FAQs

Package last updated on 24 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts