1.4.3 • Published 10 years ago

kohl v1.4.3

Weekly downloads
44
License
MIT
Repository
github
Last release
10 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

10 years ago

1.4.2

10 years ago

1.4.1

10 years ago

1.4.0

10 years ago

1.3.10

10 years ago

1.3.9

10 years ago

1.3.8

10 years ago

1.3.7

10 years ago

1.3.6

10 years ago

1.3.5

10 years ago

1.3.4

10 years ago

1.3.3

10 years ago

1.3.2

10 years ago

1.3.1

10 years ago

1.3.0

10 years ago

1.2.5

10 years ago

1.2.4

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago