Ejemplo n.º 1
0
module.exports.buildRoutes = function buildRoutes(app) {
  var method, currentUserFunc;
  var routeSummary = [];

  _.each(module.exports.controllerRoutes(), function(routes, controllerName) {
    routes.forEach(function(route) {

      method = route.method || 'get';
      routeSummary.push(method + " " + route.path);
      // determine user restrictions
      switch(route.role) {
        case 'guest':  currentUserFunc = sessionController.guestUser; break;
        case 'admin':  currentUserFunc = sessionController.adminUser; break;
        default: currentUserFunc = sessionController.currentUser; break;
      }
      // attach the route to our server
      app[method](route.path, beforeFilter(route),
                              currentUserFunc,
                              route.action,
                              finalFilter);
    });
  });

  // default route
  // app.get('/', function(req, res) {
  //  res.redirect('/someFolderInPublic');
  //  });

  return routeSummary;
}
Ejemplo n.º 2
0
	packages.forEach(function (pkg) {
		if (pkg.init) {
			inits.push(pkg.init);
		}
		for (prop in pkg) {
			if (skipProps.indexOf(prop) === -1 && typeof pkg[prop] == 'function') {
				module.exports.registerHook(prop, pkg[prop]);
			}
		}
	});
Ejemplo n.º 3
0
								}).then( function ( bundle ) {
									var options, transpiled, actual;

									options = profile.options || {};

									if ( ( bundle.imports.length && !config.imports ) || ( bundle.exports.length && !config.exports ) ) {
										throw new Error( 'config is missing imports/exports (expected ' + JSON.stringify( bundle.imports ) + ', ' + JSON.stringify( bundle.exports ) + ')' );
									}

									if ( config.imports || bundle.imports.length ) {
										assert.deepEqual( bundle.imports.sort(), config.imports.sort() );
									}

									if ( config.exports || bundle.exports.length ) {
										assert.deepEqual( bundle.exports.sort(), config.exports.sort() );
									}

									transpiled = bundle[ profile.method ]({
										strict: options.strict,
										name: options.name,
										amdName: config.amdName,
										banner: config.banner,
										footer: config.footer,
										useStrict: config.useStrict,
										sourceMap: config.sourceMap
									});

									if ( config.error ) {
										throw new Error( 'Expected error but none was raised' );
									}

									actual = makeWhitespaceVisible( transpiled.code );

									// necessary for CI
									if ( config.sourceMap ) {
										actual = actual.replace( /base64,.+/, 'base64,xyz' );
									}

									return sander.readFile( 'bundle/output/', profile.outputdir, dir + '.js' ).then( String ).then( function ( str ) {
										var expected = makeWhitespaceVisible( str );

										if ( config.strict && !options.strict ) {
											throw new Error( 'Test should fail in non-strict mode' );
										}

										assert.equal( actual, expected, 'Expected\n>\n' + actual + '\n>\n\nto match\n\n>\n' + expected + '\n>' );
									}).catch( function ( err ) {
										if ( err.code === 'ENOENT' ) {
											assert.equal( actual, '', 'Expected\n>\n' + actual + '\n>\n\nto match non-existent file' );
										} else {
											throw err;
										}
									});
								}).catch( function ( err ) {
Ejemplo n.º 4
0
 var req = protocol.request(options, function(res){
     if (-1 < [301,302,303,305,306,307].indexOf(res.statusCode)) return module.exports.ajax(method,res.headers.location,params,headers,cb,userData)
     res.setEncoding('utf8')
     var data = ''
     res.on('data', function(chunk){
         data += chunk
         cb(null, 3, data, userData)
     })
     res.on('end', function(){
         cb(null, 4, data, userData)
     })
 })
Ejemplo n.º 5
0
    attachHandlers () {
        for (let module of this.modules) {
            module.attachHandlers();
        }
        this.express.attachHandlers();
    }

    attachModule () {
        if (this.parent) {
            this.parent.express.addChild(this.mountPath, this.express);
        }
        this.express.attach('use', this.handleModule.bind(this));
    }

    // MIDDLEWARE

    handleModule (req, res, next) {
        res.locals.module = this;
        next();
    }
};
module.exports.init();

const fs = require('fs');
const path = require('path');
const ClassHelper = require('../helper/ClassHelper');
const CommonHelper = require('../helper/CommonHelper');
const ObjectHelper = require('../helper/ObjectHelper');
const AssignHelper = require('../helper/AssignHelper');
const ActionEvent = require('./ActionEvent');
const DataMap = require('./DataMap');