# json-api-server

> A NodeJS framework implementing json:api

Latest version **0.1.1** (published 2017-04-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-api-server
pnpm add json-api-server
yarn add json-api-server
bun add json-api-server
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-04-23 |
| First published | 2017-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Blake Hair |
| Maintainers | iverum |

## Links

- npm: https://www.npmjs.com/package/json-api-server
- Repository: https://github.com/Iverum/json-api-server
- Homepage: https://github.com/Iverum/json-api-server#readme
- Issues: https://github.com/Iverum/json-api-server/issues
- npm.io page: https://npm.io/package/json-api-server

## Dependencies (7)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [yayson](https://npm.io/package/yayson.md) ^2.0.3
- [restify](https://npm.io/package/restify.md) ^4.3.0
- [sqlite3](https://npm.io/package/sqlite3.md) ^3.1.8
- [sequelize](https://npm.io/package/sequelize.md) ^3.30.4
- [restify-errors](https://npm.io/package/restify-errors.md) ^4.3.0
- [restify-plugins](https://npm.io/package/restify-plugins.md) ^1.6.0

## Recent versions

- 0.1.1 (latest) — 2017-04-23
- 0.1.0 — 2017-04-23

## README

# json-api-server

A framework implementing [`json:api`](http://jsonapi.org/).

## Motivation

This framework is written with the goal of creating a tool that I can use to rapidly build APIs that conform the the json:api specification. There are a number of existing frameworks that do very similar things, but they either lack features I desire or are too lightweight and ambiguous about their use cases.

My goal with this framework is to create a tool where a developer can specify a set of resources and the framework will automatically provide CRUD for those resources, while still allowing extensions to the basic routes.

This framework is tightly coupled to the [Sequelize ORM](http://docs.sequelizejs.com/en/v3/) for now. If you're looking for a similar framework with more options for the storage solution I'd encourage you to check out [jsonapi-server](https://github.com/holidayextras/jsonapi-server). It was almost what I needed and may suit your needs.

## Usage

### Install
`npm install --save json-api-server`

### A basic API with a single resource
```js
import JsonApiServer from 'json-api-server'

const server = new JsonApiServer({ name: 'Example Server' })
const { Sequelize } = server

server.define({
  type: 'photos',
  attributes: {
    title: { type: Sequelize.STRING },
    url: {
      type: Sequelize.STRING,
      allowNull: false,
      validate: {
        isUrl: true
      }
    },
    height: {
      type: Sequelize.INTEGER,
      validate: {
        isInt: true,
        min: 1,
        max: 10000
      }
    },
    width: {
      type: Sequelize.INTEGER,
      validate: {
        isInt: true,
        min: 1,
        max: 10000
      }
    }
  }
})

server.start()
```

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