kohl
Koa web server
Last updated 5 years ago by recipher .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install kohl 
SYNC missed versions from official npm registry.

Kohl

Kohl is a koa.js web server with sane defaults.

Usage

var Server = require('kohl');

var server = new Server();

// To configure routes and middleware
server.configure('/path/to/apps');

// To start
server.start();

// To stop
server.stop();

Resources

Resource files are expected in a specific structure:

apps
  users
    resources
      routes.js
      users.js
      user.js
  groups
    resources
      routes.js
      groups.js
      group.js

This will mount routes at /users and /groups, if the apps folder is passed to server.configure.

The routes.js file should export a single function, passed with these parameters:

module.exports = function(router, resources, errors) {
  //
};

The router parameter is a koa-router, the resources is an array of all of the files in the directory, each of which should have route handlers.

For example, users.js should export a function which returns multiple handlers:

module.exports = function(errors) {
  return {
    get: function *(next) { }
  , post: function *(next) { }
  }
};

And these would be routed in routes.js like this:

module.exports = function(router, resources, errors) {
  var users = resources.users(errors);
  
  router.get('/', users.get);
  router.post('/', users.post);
};

Current Tags

  • 1.4.3                                ...           latest (5 years ago)

30 Versions

  • 1.4.3                                ...           5 years ago
  • 1.4.2                                ...           5 years ago
  • 1.4.1                                ...           5 years ago
  • 1.4.0                                ...           5 years ago
  • 1.3.10                                ...           5 years ago
  • 1.3.9                                ...           5 years ago
  • 1.3.8                                ...           5 years ago
  • 1.3.7                                ...           5 years ago
  • 1.3.6                                ...           5 years ago
  • 1.3.5                                ...           5 years ago
  • 1.3.4                                ...           5 years ago
  • 1.3.3                                ...           5 years ago
  • 1.3.2                                ...           5 years ago
  • 1.3.1                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.5                                ...           5 years ago
  • 1.2.4                                ...           5 years ago
  • 1.2.3                                ...           5 years ago
  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.2                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.5                                ...           5 years ago
  • 1.0.4                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (20)
Dev Dependencies (5)

Copyright 2014 - 2016 © taobao.org |