0.0.3 • Published 7 years ago

sunio v0.0.3

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

Sunio Api Builder

No frills, simple API builder

This is a work in progress...

How to use:

  1. Api routes are copied by folder structure. At the root of each directory you must put a routes.js and/or a schemas.js (if you want schema validation) Sample api directory structure could look like this:
api
├── routes.js
├── schemas.js
└── user
    ├── :userId
    │   └── routes.js
    └── routes.js
  1. Routes.js should be defined as an object with functions for each method (GET, POST etc), and you can return the result, as all method definitions are wrapped in Promises. I squash params into a single object, so query params, url params and body params are all in one object, and overwritten respectively.

  2. Schemas.js should define schemas (if you want to use it). for each method. An "in" object and "out" object define the schemas for that coming in and out. I use ajv to validate - so you can find more there.

  3. To run: We require express.
var express = require('express')
var app = express()
var sunio = require('<path/to/index/of/sunio>')

sunio.start(__dirname, app)

and you should be good to go!

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

0.0.0

7 years ago