OpenVeo Core server

API Docs for: 7.0.0
Show:

routeLoader

Summary

Provides functions to load routes from core and plugins configuration.

Item Index

Methods

Methods

applyRoutes

Syntax

applyRoutes

(
  • routes
  • router
)
static

Summary

Applies a list of routes to a router.

Parameters:

  • routes Array

    The list of routes to apply

  • router Object

    An express router to attach the routes to

Example:

var router = express.Router();
var routeLoader = process.require('app/server/loaders/routeLoader.js');
var routes = [
  {
    method: 'get',
    path: '/logout',
    action: [Function]
  }
];
routeLoader.applyRoutes(routes, router);

decodeRoutes

Syntax

decodeRoutes

(
  • pluginPath
  • routes
)
Array static

Summary

Gets the list of routes from a route configuration object with, for each one, the method, the path and the action to call.

Parameters:

  • pluginPath String

    The root path of the plugin associated to the routes

  • routes Object

    An object of routes

Returns:

Array:

The decoded list of routes

Example:

var routeLoader = process.require('app/server/loaders/routeLoader.js');
var routes = {
  'get /test' : 'app/server/controllers/TestController.getTestAction',
  'post /test' : 'app/server/controllers/TestController.postTestAction'
};

console.log(routeLoader.decodeRoutes('/', routes));
// [
//   {
//     method: 'get',
//     path: '/test',
//     action: Function
//   },
//   {
//     method: 'post',
//     path: 'test',
//     action: Function
//   }
// ]