apeman-app-rest

apeman app to handle restful endpoint.

## NO LONGER MAINTAINED
Last updated 4 years ago by okunishinishi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install apeman-app-rest 
SYNC missed versions from official npm registry.

apeman-app-rest

Build Status Code Climate Code Coverage npm Version JS Standard

apeman app to handle restful endpoint.

Installation

$ npm install apeman-app-rest --save

Usage

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

Apemanfile.js

/** 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,

$ apeman app my-app-01 -p 3000
'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)
})

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

License

This software is released under the MIT License.

Links

Current Tags

  • 6.0.14                                ...           latest (4 years ago)

75 Versions

  • 6.0.14 [deprecated]           ...           4 years ago
  • 6.0.13 [deprecated]           ...           4 years ago
  • 6.0.12 [deprecated]           ...           4 years ago
  • 6.0.11 [deprecated]           ...           4 years ago
  • 6.0.9 [deprecated]           ...           4 years ago
  • 6.0.8 [deprecated]           ...           4 years ago
  • 6.0.7 [deprecated]           ...           4 years ago
  • 6.0.6 [deprecated]           ...           4 years ago
  • 6.0.5 [deprecated]           ...           4 years ago
  • 6.0.3 [deprecated]           ...           4 years ago
  • 6.0.2 [deprecated]           ...           4 years ago
  • 6.0.1 [deprecated]           ...           4 years ago
  • 5.0.6 [deprecated]           ...           4 years ago
  • 5.0.5 [deprecated]           ...           4 years ago
  • 5.0.4 [deprecated]           ...           4 years ago
  • 5.0.3 [deprecated]           ...           4 years ago
  • 5.0.1 [deprecated]           ...           4 years ago
  • 5.0.0 [deprecated]           ...           4 years ago
  • 4.0.2 [deprecated]           ...           4 years ago
  • 4.0.1 [deprecated]           ...           4 years ago
  • 4.0.0 [deprecated]           ...           4 years ago
  • 3.3.5 [deprecated]           ...           4 years ago
  • 3.3.4 [deprecated]           ...           4 years ago
  • 3.3.3 [deprecated]           ...           4 years ago
  • 3.3.2 [deprecated]           ...           4 years ago
  • 3.3.1 [deprecated]           ...           4 years ago
  • 3.3.0 [deprecated]           ...           4 years ago
  • 3.1.19 [deprecated]           ...           4 years ago
  • 3.1.18 [deprecated]           ...           4 years ago
  • 3.1.17 [deprecated]           ...           4 years ago
  • 3.1.16 [deprecated]           ...           4 years ago
  • 3.1.15 [deprecated]           ...           4 years ago
  • 3.1.14 [deprecated]           ...           4 years ago
  • 3.1.13 [deprecated]           ...           4 years ago
  • 3.1.12 [deprecated]           ...           4 years ago
  • 3.1.11 [deprecated]           ...           4 years ago
  • 3.1.10 [deprecated]           ...           4 years ago
  • 3.1.9 [deprecated]           ...           4 years ago
  • 3.1.8 [deprecated]           ...           4 years ago
  • 3.1.7 [deprecated]           ...           4 years ago
  • 3.1.6 [deprecated]           ...           4 years ago
  • 3.1.5 [deprecated]           ...           4 years ago
  • 3.1.4 [deprecated]           ...           4 years ago
  • 3.1.3 [deprecated]           ...           4 years ago
  • 3.1.2 [deprecated]           ...           4 years ago
  • 3.1.1 [deprecated]           ...           4 years ago
  • 3.1.0 [deprecated]           ...           4 years ago
  • 3.0.11 [deprecated]           ...           4 years ago
  • 3.0.10 [deprecated]           ...           4 years ago
  • 3.0.9 [deprecated]           ...           4 years ago
  • 3.0.8 [deprecated]           ...           4 years ago
  • 3.0.7 [deprecated]           ...           4 years ago
  • 3.0.6 [deprecated]           ...           4 years ago
  • 3.0.5 [deprecated]           ...           4 years ago
  • 3.0.4 [deprecated]           ...           4 years ago
  • 3.0.3 [deprecated]           ...           4 years ago
  • 3.0.2 [deprecated]           ...           4 years ago
  • 3.0.1 [deprecated]           ...           4 years ago
  • 3.0.0 [deprecated]           ...           4 years ago
  • 2.2.4 [deprecated]           ...           4 years ago
  • 2.2.3 [deprecated]           ...           4 years ago
  • 2.2.2 [deprecated]           ...           4 years ago
  • 2.2.1 [deprecated]           ...           4 years ago
  • 2.2.0 [deprecated]           ...           4 years ago
  • 2.1.2 [deprecated]           ...           4 years ago
  • 2.1.1 [deprecated]           ...           4 years ago
  • 2.1.0 [deprecated]           ...           4 years ago
  • 2.0.1 [deprecated]           ...           4 years ago
  • 2.0.0 [deprecated]           ...           4 years ago
  • 1.0.5 [deprecated]           ...           4 years ago
  • 1.0.4 [deprecated]           ...           5 years ago
  • 1.0.3 [deprecated]           ...           5 years ago
  • 1.0.2 [deprecated]           ...           5 years ago
  • 1.0.1 [deprecated]           ...           5 years ago
  • 1.0.0 [deprecated]           ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (15)
Dev Dependencies (22)

Copyright 2014 - 2016 © taobao.org |