# js-api

> JavaScript/JSON objects to REST API in seconds.

Latest version **1.5.0** (published 2021-05-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-api
pnpm add js-api
yarn add js-api
bun add js-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2021-05-22 |
| First published | 2016-10-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 (+7 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 35 |
| Author | Teoman Soygul |
| Maintainers | soygul |

## Links

- npm: https://www.npmjs.com/package/js-api
- Repository: https://github.com/soygul/js-api
- Issues: https://github.com/soygul/js-api/issues
- npm.io page: https://npm.io/package/js-api

## Dependencies (7)

- [koa](https://npm.io/package/koa.md) 1.6.2
- [lodash](https://npm.io/package/lodash.md) 4.17.21
- [request](https://npm.io/package/request.md) 2.88.2
- [koa-cors](https://npm.io/package/koa-cors.md) 0.0.16
- [koa-route](https://npm.io/package/koa-route.md) 2.4.2
- [koa-logger](https://npm.io/package/koa-logger.md) 1.3.1
- [koa-bodyparser](https://npm.io/package/koa-bodyparser.md) 2.5.0

## Recent versions

- 1.5.0 (latest) — 2021-05-22
- 1.4.0 — 2019-09-15
- 1.3.0 — 2019-07-01
- 1.2.0 — 2016-10-20
- 1.1.0 — 2016-10-20
- 1.0.0 — 2016-10-19

## README

# js-api
Creates a REST API server from given JavaScript/JSON objects.
Uses [Koa](https://github.com/koajs/koa) for the REST API.
Extendable with custom routes and middleware.

## Quickstart
Install the package in your project directory:

```bash
npm install js-api
```

Start js-api server with some data:

```javascript
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](http://localhost:3000/posts) and you will see the posts in JSON format.

## Custom Routes and Middleware
See [example.js](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:

```bash
npm install
npm start
```

And browse to [http://localhost:3000/posts](http://localhost:3000/posts) to see the contents of the example.

## License
MIT

---
_Source: https://npm.io/package/js-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
