4.0.0 • Published 7 years ago

status-interfaces v4.0.0

Weekly downloads
33
License
-
Repository
github
Last release
7 years ago

status-interfaces

Function for setting HTTP Status interfaces and an object for content quickly.

Note: Metadata is wrapped in meta obj.

Install

npm i status-interfaces

API

si(code, [{content}], [[error objects]])

Usage

import si from 'status-interfaces'

router.get(`/:id`, ctx => {
  const record = find(dataSource, o => o.id === Number(ctx.params.id))

  if (record) {
    ctx.body = si(200, {
      record
    })
  } else {
    ctx.body = si(404, undefined, [ // this doesn't actually work because Koa doesn't escape here. I'll write some Koa middleware when time allows.
      {
        code: 1,
        text: `Ya dun goofed...`
      }
    ])
  }
})
4.0.0

7 years ago

3.1.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago