0.3.2 • Published 8 years ago
annotation-api v0.3.2
Documentation
Node.js routing using annotations
This module allows you, to define your routes with annotations instead of using nested callbacks and exports. It also provides a validator, to automatically validate incoming requests. You can use it with express framework. Otherwise you can use the custom (flat and fast) built-in web server.
Read the Changelog.
Annotations
Create a Route
/**
* es6 example
* @Method("route");
* @Route("/somewhere");
* @HTTP("POST");
* @Append("MyTransferObject.class");
* @Query({ ... });
* @Security("is_authenticated");
* @RedirectErrorHandler("/err");
*/
module.exports.route = (req, res) => {
res.end('validated');
};
Installation
- Clone this repository
- Run
npm install
- Run
npm start
Usage
var app = require('express')();
var api = require('annotation-api')(app);
api.setApiPrefix('/my-base-url');
api.generate(__dirname + '/actions/**/*.js', callback);
api.generate([ __dirname + '/my-file.js' ]);
Example
Can be found here
Doc-Builder
Create a documentation via CLI
Tests
Execute the tests, using npm test
.