Skip to content

Latest commit

 

History

History
42 lines (32 loc) · 1.01 KB

README.md

File metadata and controls

42 lines (32 loc) · 1.01 KB

restify-resourcify

Declarative bindings to restify service endpoint registration.

npm version Dependency Status Build Status

Getting Started

npm install restify-resourcify

Note: You need to have restify installed. Take a look at the peerDependencies in package.json for version compatibility.

Usage

import {Resource, path, GET} from 'restify-resourcify';

@path('/users/')
class UserResource extends Resource {

  @GET
  async fetchUsers(request) {
    return {
      data: await db.loadUsers
    };
  }

  @GET
  @path(':id')
  async fetchUser(request) {
    return {
      data: await db.loadUser({
        id: request.params.id
      })
    };
  }

}