# apeman-app-rest

> apeman app to handle restful endpoint.

Latest version **6.0.14** (published 2016-06-30) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install apeman-app-rest
pnpm add apeman-app-rest
yarn add apeman-app-rest
bun add apeman-app-rest
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 6.0.14 |
| Published | 2016-06-30 |
| First published | 2015-11-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 15 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Taka Okunishi |
| Maintainers | okunishinishi |
| Keywords | apeman, app, rest |

## Links

- npm: https://www.npmjs.com/package/apeman-app-rest
- Repository: https://github.com/apeman-app-labo/apeman-app-rest
- Homepage: https://github.com/apeman-app-labo/apeman-app-rest#readme
- Issues: https://github.com/apeman-app-labo/apeman-app-rest/issues
- npm.io page: https://npm.io/package/apeman-app-rest

## Dependencies (15)

- [co](https://npm.io/package/co.md) ^4.6.0
- [qs](https://npm.io/package/qs.md) ^6.2.0
- [argx](https://npm.io/package/argx.md) ^2.0.2
- [uuid](https://npm.io/package/uuid.md) ^2.0.2
- [debug](https://npm.io/package/debug.md) ^2.2.0
- [defaults](https://npm.io/package/defaults.md) ^1.0.3
- [pluralize](https://npm.io/package/pluralize.md) ^3.0.0
- [stringcase](https://npm.io/package/stringcase.md) ^3.0.1
- [apemanerror](https://npm.io/package/apemanerror.md) ^3.1.0
- [apemanmodel](https://npm.io/package/apemanmodel.md) ^2.0.10
- [apemanpromise](https://npm.io/package/apemanpromise.md) ^3.1.1
- [apeman-app-noop](https://npm.io/package/apeman-app-noop.md) ^3.0.1
- [apeman-app-route](https://npm.io/package/apeman-app-route.md) ^5.0.2
- [apeman-app-jsonapi](https://npm.io/package/apeman-app-jsonapi.md) ^3.0.0
- [apeman-app-validate](https://npm.io/package/apeman-app-validate.md) ^5.0.0

## Recent versions

- 6.0.14 (latest) — 2016-06-30
- 6.0.13 — 2016-06-27
- 6.0.12 — 2016-06-20
- 6.0.11 — 2016-06-19
- 6.0.9 — 2016-06-19
- 6.0.8 — 2016-06-18
- 6.0.7 — 2016-06-18
- 6.0.6 — 2016-06-18
- 6.0.5 — 2016-06-14
- 6.0.3 — 2016-06-13
- 6.0.2 — 2016-06-13
- 6.0.1 — 2016-06-13
- 5.0.6 — 2016-06-06
- 5.0.5 — 2016-06-05
- 5.0.4 — 2016-06-05
- … 60 more at https://npm.io/package/apeman-app-rest/versions

## README

apeman-app-rest
==========

<!---
This file is generated by ape-tmpl. Do not update manually.
--->

<!-- Badge Start -->
<a name="badges"></a>

[![Build Status][bd_travis_shield_url]][bd_travis_url]
[![Code Climate][bd_codeclimate_shield_url]][bd_codeclimate_url]
[![Code Coverage][bd_codeclimate_coverage_shield_url]][bd_codeclimate_url]
[![npm Version][bd_npm_shield_url]][bd_npm_url]
[![JS Standard][bd_standard_shield_url]][bd_standard_url]

[bd_repo_url]: https://github.com/apeman-app-labo/apeman-app-rest
[bd_travis_url]: http://travis-ci.org/apeman-app-labo/apeman-app-rest
[bd_travis_shield_url]: http://img.shields.io/travis/apeman-app-labo/apeman-app-rest.svg?style=flat
[bd_travis_com_url]: http://travis-ci.com/apeman-app-labo/apeman-app-rest
[bd_travis_com_shield_url]: https://api.travis-ci.com/apeman-app-labo/apeman-app-rest.svg?token=
[bd_license_url]: https://github.com/apeman-app-labo/apeman-app-rest/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/apeman-app-labo/apeman-app-rest
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/apeman-app-labo/apeman-app-rest.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/apeman-app-labo/apeman-app-rest.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/apeman-app-labo/apeman-app-rest
[bd_gemnasium_shield_url]: https://gemnasium.com/apeman-app-labo/apeman-app-rest.svg
[bd_npm_url]: http://www.npmjs.org/package/apeman-app-rest
[bd_npm_shield_url]: http://img.shields.io/npm/v/apeman-app-rest.svg?style=flat
[bd_standard_url]: http://standardjs.com/
[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg

<!-- Badge End -->


<!-- Description Start -->
<a name="description"></a>

apeman app to handle restful endpoint.

<!-- Description End -->


<!-- Overview Start -->
<a name="overview"></a>



<!-- Overview End -->


<!-- Sections Start -->
<a name="sections"></a>

<!-- Section from "doc/guides/01.Installation.md.hbs" Start -->

<a name="section-doc-guides-01-installation-md"></a>
Installation
-----

```bash
$ npm install apeman-app-rest --save
```


<!-- Section from "doc/guides/01.Installation.md.hbs" End -->

<!-- Section from "doc/guides/02.Usage.md.hbs" Start -->

<a name="section-doc-guides-02-usage-md"></a>
Usage
---------

1. Define an app within Apemanfile.js
2. Call the app via apeman app command.

**Apemanfile.js**
```javascript
/** This is an example Apemanfile to use apeman-app-rest */

'use strict'

const db = require('./db') // Apeman db modle instance
const { User } = db.models

module.exports = {
  $pkg: { /* ... */ },
  $apps: {
    // Define your own app.
    'my-app-01': {
      // Map url and handlers.
      '/': [
        require('apeman-app-rest')(User, {
          // Options
        })
      ]
    }
  }
}

```

Then,
```bash
$ apeman app my-app-01 -p 3000
```


```javascript
'use strict'

const apemanrequest = require('apemanrequest')
const co = require('co')
const assert = require('assert')

let request = apemanrequest.create({ jar: true })

co(function * () {
  // Create a resource.
  {
    let res = yield request({
      method: 'POST',
      url: 'http://localhost:3000/user',
      form: {
        account_name: 'foo_bar',
        email: 'apbc@example.com'
      }
    })
    /* ... */
  }

  // Get a resource.
  {
    let res = yield request({
      method: 'GET',
      url: 'http://localhost:3000/user/1' // Pass resource id as url-param.
    })
    /* ... */
  }

  // List resource.
  {
    let res = yield request({
      method: 'GET',
      url: 'http://localhost:3000/user?account_name.$like=foo&limit=5&offset=5'
    })
    /* ... */
  }

  // Update the resource.
  {
    let res = yield request({
      method: 'PATCH',
      url: 'http://localhost:3000/user/1', // Pass resource id as url-param.
      form: {
        account_name: 'foo_bar2_updated'
      }
    })
    /* ... */
  }

  // Destroy the resource.
  {
    let res = yield request({
      method: 'DELETE',
      url: 'http://localhost:3000/user/1' // Pass resource id as url-param.
    })
    /* ... */
  }
}).catch((err) => {
  console.error(err)
})

```


<!-- Section from "doc/guides/02.Usage.md.hbs" End -->

<!-- Section from "doc/guides/03.Signature.md.hbs" Start -->

<a name="section-doc-guides-03-signature-md"></a>
Signature
-------

#### apemanAppRest(models, options) -> function

apeman app to handle restful endpoint.

##### Args

| Name | Type | Default | Description |
| --- | ---- | --- | --- |
| models | object  |  | Model objects. |
| options | object  |  | Optional settings. |
| options.pathname | function  | '/'+apemanmodel.toType(model) | Spec path name. |
| options.knock | Endpoint|boolean  |  |  |
| options.spec | Endpoint|boolean  |  |  |
| options.list | Endpoint|boolean  |  |  |
| options.create | Endpoint|boolean  |  |  |
| options.bulkUpdate | Endpoint|boolean  |  |  |
| options.bulkDestroy | Endpoint|boolean  |  |  |
| options.one | Endpoint|boolean  |  |  |
| options.update | Endpoint|boolean  |  |  |
| options.destroy | Endpoint|boolean  |  |  |
| options.relatedList | Endpoint|boolean  |  |  |
| options.relatedCreate | Endpoint|boolean  |  |  |
| options.relatedUpdateBulk | Endpoint|boolean  |  |  |
| options.relatedDestroyBulk | Endpoint|boolean  |  |  |
| options.relatedOne | Endpoint|boolean  |  |  |
| options.relatedUpdate | Endpoint|boolean  |  |  |
| options.relatedDestroy | Endpoint|boolean  |  |  |
| options.relationList | Endpoint|boolean  |  |  |
| options.relationCreate | Endpoint|boolean  |  |  |
| options.relationUpdate | Endpoint|boolean  |  |  |
| options.relationDestroy | Endpoint|boolean  |  |  |


<!-- Section from "doc/guides/03.Signature.md.hbs" End -->


<!-- Sections Start -->


<!-- LICENSE Start -->
<a name="license"></a>

License
-------
This software is released under the [MIT License](https://github.com/apeman-app-labo/apeman-app-rest/blob/master/LICENSE).

<!-- LICENSE End -->


<!-- Links Start -->
<a name="links"></a>

Links
------

+ [apeman](https://github.com/apeman-labo/apeman)
+ [JSON API](http://jsonapi.org/)
+ [apeman-app](https://github.com/apeman-cmd-labo/apeman-app)

<!-- Links End -->

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