getapi - simpliest way to build API
example
Just add some comments for API to fly
/*** @Route * @UrlMapping (url = '/apicall/math/add')*/moduleexports{ res;}
see more examples: https://github.com/edjafarov/getapi/blob/master/examples/apis/math.js
install
$npm install getapi -g
use
-
Create you node.js files in some folder.
-
Place comments
@Route
- means that this function should handle api call.@UrlMapping (url = '[url]')
allows you to assign url for the function. You can assign url's in usual express manner with named placeholders. But unlike express if you will name one of arguments of a function same as placeholder this argument will be resolved.
/*** @Route * @UrlMapping (url = '/apicall/math/pow/:num')*/moduleexports{ //num will be resolved to the value of placeholder res;}
-
$ getapi --dir=[path-to-folder] --port=[port]
(if you rungetapi
without args default will use current folder and 80 port - aware that in linux to use 80 port you need to be sudo) -
that's it!
OR
use it programmatically
var express = ;var getapi = ; var app = express; var app = express; app; app; app;
License
MIT