JSPM

  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q49681F
  • License MIT

A node module that implements the behaviour-driven design and map-queue algorithm

Package Exports

  • backend-js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (backend-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

backendjs

A node module that implements the behaviour-driven design and map-queue algorithm

Installation

npm install backend-js

Usage

var backend = require('backend-js');
var behaviour = backend.behaviour('/api/v1');

var model = backend.model();
var User = model({

  name: 'User'
}, {

  username: String,
  password: String
});

behaviour({

  name: 'GetUsers',
  version: '1',
  path: '/users',
  method: 'GET'
}, function(init) {

  return function() {

    var self = init.apply(this, arguments).self();
    self.begin('Query', function(key, businessController, operation) {

        operation
          .entity(new User())
          .append(true)
          .apply();
      });
  };
});

Note

you should define your own data access layer like following

var backend = require('backend-js');

var ModelController = function () {

    self.removeObjects = function (queryExprs, entity, callback) {

        // do remove
    };
    self.newObjects = function (objsAttributes, entity, callback) {

        // do add new
    };

    self.getObjects = function (queryExprs, entity, callback) {

        // do select
    };
    self.save = function (callback, oldSession) {

        // do select
    };
};

ModelController.defineEntity = function (name, attributes) {

    // define entity
    return entity;
};

ModelController.prototype.constructor = ModelController;

backend.setModelController(new ModelController());

ToDo

  1. caching
  2. enhance queue-map algorithm
  3. add streams
  4. add module for external integrations