Git Product home page Git Product logo

express-dynamic-response's Introduction

Express Dynamic Response

Express response is a middleware which allow create custom responses based on express.response class.

How to use

First you need to add as project dependency:

$ npm install express-dynamic-response --save

Then you need to configure your response directory:

$ cd <YOUR_PROJECT>
$ mkdir <RESPONSE_FOLDER>

Then just setup as a new middleware (ES6):

import expressResponse from 'express-dynamic-response'
app.use(expressResponse(path.join(__dirname, <YOUR_RESPONSE_FOLDER>))

Then just setup as a new middleware (ES5):

var expressResponse = require('express-dynamic-response');
app.use(expressResponse(path.join(__dirname, <YOUR_RESPONSE_FOLDER>))

After setup a new middleware you can go to response folder then create a new response per file:

//this is a express.response class so you have everthing you need here
module.exports = function() {
    this.status(200);
    this.send('Hello Im a custom response');
};

You can create more dynamic response using objects by params:

//this is a express.response class so you have everthing you need here
module.exports = function(obj) {
    this.status(200);
    this.json(obj);
};

Be creative :)

For any doubts or problem please open a issue

License

MIT

express-dynamic-response's People

Contributors

leonanluppi avatar

Stargazers

tavoli avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.