1.4.3 • Published 8 years ago

kohl v1.4.3

Weekly downloads
44
License
MIT
Repository
github
Last release
8 years ago

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);
};
1.4.3

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.10

9 years ago

1.3.9

9 years ago

1.3.8

9 years ago

1.3.7

9 years ago

1.3.6

9 years ago

1.3.5

9 years ago

1.3.4

9 years ago

1.3.3

9 years ago

1.3.2

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.5

9 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago