Logo: Relish

  1. Sign in

Project: Garret


By using the module interface it is possible to extend the garret core
components. In fact, also the core components are modules, but they are
always loaded to provide a reasonable starting point for other modules.

The core components include Logging, an HTTP Stack, Typed Middlewares, a Redis Client and a
Graphstore Client.

Implementing a Module

A garret module is a Node.js module that exports a function with two
parameters app and next. The app object is the central garret object
that is used to communicate with other modules. The next function is a
callback that must be called if the module is ready. So the most basic
module could be:

module.exports = function(app, next) {
   app.logger.log('hello module!');
I have a Node.js module that takes the arguments app and next
that module is loaded by garret
the next argument should be a function
the app argument should be an object
the app argument should have the keys
logger, http, typed, redis, graphstore

Last published over 6 years ago by Niclas Hoyer.