Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bytesleo/express-easy-helper
Helper API for express (success, badRequest, unauthorized, forbidden, notFound, unsupportedAction, invalid, error)
https://github.com/bytesleo/express-easy-helper
express express-helper express-response helper helper-promises node-helper response-code success
Last synced: about 2 months ago
JSON representation
Helper API for express (success, badRequest, unauthorized, forbidden, notFound, unsupportedAction, invalid, error)
- Host: GitHub
- URL: https://github.com/bytesleo/express-easy-helper
- Owner: bytesleo
- License: mit
- Created: 2017-07-18T16:07:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:51:40.000Z (almost 2 years ago)
- Last Synced: 2024-10-03T10:37:39.485Z (3 months ago)
- Topics: express, express-helper, express-response, helper, helper-promises, node-helper, response-code, success
- Language: JavaScript
- Homepage:
- Size: 428 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-easy-helper
> Simple helper module for express
## Installation
yarn
```bash
yarn add express-easy-helper
```npm
```bash
npm install express-easy-helper --save
```## Usage
```javascript
import { success, unauthorized, forbidden, error } from "express-easy-helper";
import express from "express";
const app = express();// success
app.get("/", (req, res) => {
success(res, { hello: "world" });
});// unauthorized
app.get("/unauthorized", (req, res) => {
unauthorized(res);
});// forbidden
app.get("/protected", (req, res) => {
forbidden(res);
});// error
app.get("/error", (req, res) => {
error(res);
});
```## Method's
```javascript
// 200
success(res);// 400
badRequest(res);// 401
unauthorized(res);// 403
forbidden(res);// 404
notFound(res);//405
unsupportedAction(res);//422
invalid(res);// 500
error(res);
```## Options
```javascript
// Basic
success(res);// Code status
success(res, 201);// Data
success(res, { hello: "world" });// Code status and data
success(res, 201, { hello: "world" });
```## License
MIT © [Leonardo Rico](https://github.com/kevoj/express-easy-helper/blob/master/LICENSE)