https://github.com/uphold/mali-error-mapper
Mali gRPC error mappers and middleware
https://github.com/uphold/mali-error-mapper
Last synced: 2 months ago
JSON representation
Mali gRPC error mappers and middleware
- Host: GitHub
- URL: https://github.com/uphold/mali-error-mapper
- Owner: uphold
- License: mit
- Created: 2019-10-11T14:30:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T21:57:16.000Z (almost 2 years ago)
- Last Synced: 2025-01-29T07:30:44.196Z (4 months ago)
- Language: JavaScript
- Size: 1.82 MB
- Stars: 0
- Watchers: 51
- Forks: 1
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Mali error mapper
Mali gRPC error mappers and middleware.
## Middleware
This middleware maps all non `GrpcError` errors to a `GrpcError` formatted accordingly.
## Status
[](https://travis-ci.com/uphold/mali-error-mapper)
## Installation
Install the package via `yarn`:
```sh
❯ yarn add mali-error-mapper
```or via `npm`:
```sh
❯ npm install mali-error-mapper --save
```## Usage
Using default mapping:
```javascript
'use strict';const errorMapperMiddleware = require('mali-error-mapper');
const app = new Mali();app.use(errorMapperMiddleware());
```Using custom mappers:
```javascript
'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