Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Documented Connect/Express Router

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 tests
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 doc.jade
Octocat-spinner-32 index.js
Octocat-spinner-32 json2wadl.js
Octocat-spinner-32 methods.js
Octocat-spinner-32 package.json
README.md

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 chagnes 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

Something went wrong with that request. Please try again.