JSPM

koapi

0.2.27
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 277
  • Score
    100M100P100Q65941F
  • License MIT

RESTful API framework based on koajs

Package Exports

  • koapi

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (koapi) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Koapi

RESTful API framework based on koa and bookshelf

Build a RESTful API with Koa will be dead simple

Install

npm install koapi

I recommended you install a globaly version for advanced usage.

npm install -g koapi

Quick Usage

Create server.js below

import Koapi, {Router} from 'koapi';

const app = new Koapi();

// Router
const posts = new Router();
posts.get('/', function*(){
  this.body = 'Hello World';
});

app.run({
  port: 4000,
  debug: true,
  cors: true,
  serve: {
    root: __dirname + '/public', // serve static file in ./public
  },
  routers: [ posts ], // Routers
});

Now run it

babel-node server.js

Advanced Usage

Create your project folder

mkdir /path/to/project
cd /path/to/project

Init a boilerplate

koapi init ./

For the boilerplate details, see koapi-boilerplate