Logo: Relish

  1. Sign in

Project: Garret

Modules

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.

Scenarios
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!');
   next();
};
Given
I have a Node.js module that takes the arguments app and next
And
that module is loaded by garret
Then
the next argument should be a function
And
the app argument should be an object
And
the app argument should have the keys
logger, http, typed, redis, graphstore

Last published over 6 years ago by Niclas Hoyer.