Giter Site home page Giter Site logo

node-docrouter's Introduction

build status

DocRouter

A Connect/Express router wrapper which exposes a formatted description of the available services of a server. The documentation is available is multiple formats (Html, Wadl, Json).

The usage mimics the regular router's behavior.

Retrieving the documentation

Two options:

Supported outputs

  • JSON (Accept: application/json)
  • WADL (Accept: text/xml)
  • HTML (Accept: text/html)

docRouter follows the RestDoc spec (https://github.com/RestDoc), RestDoc is a live spec so please expect changes over time.

Examples

Connect Style

var docRouter = require('docrouter').DocRouter;
var server = connect.createServer(docRouter(connect.router, "http://myservice.mydomain.com", function(app) {
    app.get('/:app', handleGetApp,
        {
            id: "GetApp",
            doc: "Gets the app",
            params: {
                app: {
                    style: "template",
                    type: "string",
                    required: true
                }
            },
            response: {
                doc: "Description of response body",
                example: "{ name: 'myApp' }"
            }
        });
    app.post('/:app', handleAddApp,
        {
            id: "UpdateApp",
            doc: "Updates the app",
            params: {
                app: {
                    style: "template",
                    type: "string",
                    required: true
                }
            },
            request: {
                doc: "Description of request body",
                params: {
                    name: { doc: "app new name", type: "string", reuired: true }
                },
                example: "POST /myApp \n { name: 'my new app' }"
            }
        });
});
);
server.listen(5000);

Express Style

var docRouter = require('docrouter').DocRouter;
var app = express.createServer();

docRouter(app, "http://myservice.mydomain.com");

app.get('/:app', handleGetApp,
    {
        id: "GetApp",
        doc: "Gets the app",
        params: {
            app: {
                style: "template",
                type: "string",
                required: true
            }
        }
    });

app.post('/:app', handleAddApp,
    {
        id: "UpdateApp",
        doc: "Updates the app",
        params: {
            app: {
                style: "template",
                type: "string",
                required: true
            }
        }
    });

app.listen(5000);

#Credits#

#License# MIT

node-docrouter's People

Contributors

saary avatar gilad61 avatar

Watchers

 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.