Risotto is a VC framework based on koajs.
Risotto requires redis to run
$ npm install risotto
Risotto needs a special project structure to run:
Require Risotto where ever you want and pass the those folders to the initialize method like this: it makes heavy use of es6 harmony features and thus requires node´s --harmony flag
After calling initialize Risotto will boot up and look up all controllers in /app/controllers. It will bind all routes configured in the /config/routes.yml file for you. Be Aware Risotto will register a global variable named "Risotto".
Controllers take the main part in handling incoming requests and processing them.
A controller consists of a group of methods which handle one type of request defined in the route. Example:
moduleexports = RisottoController;
The params object passed to each method contains every parameter that might be passed to the server. In the methods you have access to the following methods:
Generator Function which renders and returns a html template at path. Everything into the options object will be available as variable in the template.
setter/getter for the response body
setter/getter for the response status code
Redirects the Request to path
Returns an http error with the given code and optional with the message.
access to the koa attachment method
access to the koa method json
access to the koa attribute type
access to the koa attribute session
access to the koa request object
access to the koa response object
The routes file in the config directory contains all the individual routes to the controllers. It has the following syntax:
routes:GET /:username/: Profile.show
Routes can be namespaced in the following way:
routes:project:GET :id-(.+): Project.show
moduleexports = RisottoApplication;
Filters are a way to reuse common controller functionality. We differentiate between beforeFilter which run before the controller and the afterFilter which run after the actual controller. ###Using Filters
Create a new file in app/filters and call
Risotto.before to register a beforeFilter and
Risotto.after to register a afterFilter.