modrain
v0.0.2
Published
A WFM module providing client and backend for file support
Downloads
2
Readme
ModRain
ModRain (Module Rain) modular architecture framework for modular client and server applications written in javascript/typescript. Use microservices architecture for client and server side javascript apps.
Idea
ModRain allows to write fully modularized javascript applications. ModRain can be used for large scale frontend and node.js backend applications were reusability is expected.
Quick start
Create new module (node.js app)
mkdir mymodule
cd mymodule
npm init
npm install modrain --save
touch index.js
Register module and create module interface.
var modrain = require("modrain");
var MODULE_NAME = "user";
var ACTION = "create";
// Register new module in namespace
var userModule = modrain.registerModule(MODULE_NAME);
// We can unregister module as well
//var userModule = modrain.unregisterModule(MODULE_NAME);
// Using method interface
userModule.registerHandler(ACTION, function(userObject, callback){
// Implementation to save userObject
// ...
callback(null, "success");
// In case of error
callback("error");
});
TODO Change API to register module with entire module interface passed as second parameter.
Consuming module
var modrain = require("modrain");
modrain.getModule(user).call("create", userObject, function(err, result){
// impl
});
// if global mount option is enabled
modrain.user.create(userObject, function(err, result){
// impl
});
Consuming module - promises interface
var modrain = require("modrain");
modrain.getModule(user).call("create",userObject).then(function(err, result){
// impl
});
Architecture
ModRain allows us to register modules into module registry and then define complete set of the actions on each module.
Interfaces
- Callbacks
- Promises
Classical callback interface is supported by default To enable promises use:
npm install --save bluebird
modrain.usePromises(true);
Modules
Modules can expose functionality to our application.
Transports
ModRain defines abstraction layer for module communications. Modules can interact with each other using transport in the background. Currently library supports following transports:
- Direct method calls (globals)
- Observer (ReactiveComponents)
- Publish/Subscribe (using mediator)
- HTTP (TODO)
Promises
Using promise library
Publish/Subscribe
Using mediator pattern and topics to register for some actions
API
ModRain is under active development. API may change.
TODO