In the previous post we introduce Noradf (check out the Github Organization for more info)

We’re going to continue with the ‘what a noradf application looks like‘ section

What a Noradf application looks like


We saw how to install a module. Now we are going to see what it looks like

All modules have a modules.json file. In this file we define several properties:

  • name: The name of the module. This name will be used for dependency injection. If there is any hyphen (-) it will be convert to an underscore (_)
  • version: The version of the module
  • dependencies: Npm dependencies of the module
  • bowerDependencies: Bower dependencies of the module
  • config: Config properties that will be added to our config/env/common.json file

A module has to have a module.js file too. The framework will load the file in order to init the module. Here’s an example:

'use strict';

module.exports = function (config) {
    if ( {

    var myNumbers = ['one', 'two'];
    return {
        numbers: myNumbers

In this example, we are injecting the config module. This module is defined in Noradf. It’s an JSON object that contains the config properties of our application, based on the files we provided

If we return an object in our module, we can inject this object in other modules and use it

Noradf uses Express as the server engine. We can inject the next modules too:

  • app: This module is our Express object. We can use it for routing
  • passport: If you need to use passport features you can inject this module
  • router: This module has a function called session. You can use this function to override the default session behaviour. There’s an example in the noradf-mongo module.js file
  • assets: This module is based on wlist. You can use it to add your module assets (js, css, img, …) in the application. It has two functions:
    • put(module, type, assetPath, weight, name): Puts an asset in your application assets list. E.g. from noradf-angular-dropzone module:
      'use strict';
      module.exports = function (assets) {
          assets.put(this, 'js', 'js/directives/noradf-angular-dropzone.js');
          assets.put(this, 'bower_js', 'dropzone/dist/min/dropzone.min.js');
          assets.put(this, 'bower_css', 'dropzone/dist/min/dropzone.min.css', 1000);
          assets.put(this, 'bower_css', 'dropzone/dist/min/basic.min.css', 1001);
    • get(type): If you provide the type it will return the asset type list, otherwise it will provide all the assets lists

In the next post we will see how to define the server and front logic of our module. Stay tuned!

Comparte este articuloShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn