@zishone/jasenda
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

jasenda NPM Build Coverage License

A middleware to add jsend helper functions to the response object.

Installation

$ npm i @zishone/jasenda

Usage

const express = require('express');
const { jsend } = require('@zishone/jasenda');

const app = express();

app.use(jsend());

app.get('/success', (req, res) => {
  res.jsend.success({ /* any data */ }/*, 2XX*/);
});

app.get('/fail', (req, res) => {
  res.jsend.fail({ /* any data */ }/*, 4XX*/);
});

app.get('/error', (req, res) => {
  res.jsend.fail('An error message'/*, 5XX, errorCodeNumber, { any data }*/);
});

app.listen(port, () => {
  console.log('Listening at port 3000')
})

Authors

  • Zishran Garces

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i @zishone/jasenda

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

7.75 kB

Total Files

12

Last publish

Collaborators

  • zishone