1.0.3 • Published 7 years ago

rcs-jsonstyle v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Json Style

A Json Response module for ExpressJS. Used by Red Carpet Solutions To standardize Json Responses from the server

Installation

npm i -S rcs-jsonstyle

How to Use

This Module only works with ExpressJS. Once you have your ExpressJS Application, It's actually fairly simple:

const express = require('express');
var app = express();
// Standard express App Declaration


const rcsres = require('rcs-jsonstyle');
// Require the module



//Write your standart ExpressJS Middleware
app.get('/someroutes',(req,res)=>{
    var data = ImportFromDatabase() // Dummy Function
    if(data){
        rcsres.json(res, data); // Pass in the response and the data
        // And You're Done
    } else {
        rcsres.error(res, "SOME ERROR MESSAGE"); // Send an Error response
        // Error response have status code 500 and a diffrent format
    }
});

you can check the modules/res.module.js file to see all the responses available (We covered the most frequent ones)

More Responses

Please leave an Issue with the response you want and we will add it to the library. Issues

Red Carpet Solutions

We're a Company What do we do!

This project is backed By redcarpetsolutions

About the Author

I'm Khaled Romdhane but mostly known as heiyuki. My handle is : @heiyukidev.

I Work at this amazing Company @redcarpetsolutions don't hesitate to go check us out.

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago