1.5.0 • Published 3 years ago

js-api v1.5.0

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

js-api

Creates a REST API server from given JavaScript/JSON objects. Uses Koa for the REST API. Extendable with custom routes and middleware.

Quickstart

Install the package in your project directory:

npm install js-api

Start js-api server with some data:

var jsapi = require('js-api');

var data = {posts: [{id: 'p1', title: 'first post', body: 'lorem ipsum'}]};

jsapi.start(data, 3000);

Now browse to http://localhost:3000/posts and you will see the posts in JSON format.

Custom Routes and Middleware

See example.js for a complete example with custom middleware and custom route definitions for resources.

You can download the entire repo and start the example directly with:

npm install
npm start

And browse to http://localhost:3000/posts to see the contents of the example.

License

MIT

1.5.0

3 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago