Skip to content

ajsun/sunio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

A nice API builder

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published