noradf

While I was working for Virtual Desk I developed a framework for Rapid Application Development written in Java. I want to do the same but now with NodeJS and the result is Noradf (see the organization in Github)

I need an extensible framework, based on modules, with dependency injection and with auto discoverable features. It must work with any database, not only MongoDB or MySQL and it must be Open Source

With these premises I’ve done the first version. It’s simple but it works. Let’s see it in action:

Installing Noradf CLI

First of all we need to install Noradf CLI. It’s as simple as npm install noradf-cli -g. Once is installed we can init our Noradf project

noradf init

We need to enter our project name and all the dependecies will be installed and the package.json file will be created. The config files will be created too under the config/env folder

What does a Noradf application looks like

Configuration

In a Noradf application we have a config/env folder. This folder contains at least one file called common.json. This file contains all the configuration options for the application

If you want to override an option for your enviroment you can create a file named name_of_your_enviroment.json (e.g. development.json or production.json)

It will look for the NODE_ENV enviroment property to look for the appropiate config file. If there is no NODE_ENV enviroment property it will look for development.json

E.g.: If you have a development.json file with the property debug to true and in the file common.json is set to false it will be evaluated to true. If you don’t have the debug property in development.json the value from common.json will be the evaluated value

If the file common.json doesn’t exist the configuration won’t be loaded, even if another config file exists

Modules

The framework is based on modules. In the framework Github organization you can find some modules. If you want to install a module in your application you can use the CLI, e.g.:

noradf install noradf-mongo

This will install the noradf-mongo module from the Github repository. It will clone the module under the modules folder and then it will install the npm and bower dependencies

After that, it will add the module configuration to your config/env/common.js file if necessary and it will add the module to a file named noradf.json

If you want to reinstall a module you can use the -f or --force option

If you want to install a module from a local path you can use the -p or --path option

noradf install noradf-mongo -p ~/noradf-modules/noradf-mongo

If you have a project without the modules installed but it has the modules in the noradf.json file you can install all the modules with noradf install command

We will continue in the next parts of the article. Stay tuned!