Permalink
Browse files

Merge pull request #1386 from yahoo/client-routes

Route annotations in routes.json and hidding routes from the client
  • Loading branch information...
2 parents 8838fc3 + 32b34f2 commit 471631f10d1a7ba47f6c08be8a8fbb4ba5b36ef0 @aljimenez aljimenez committed Jul 14, 2014
@@ -69,7 +69,7 @@ YUI.add('mojito-deploy-addon', function (Y, NAME) {
initializer, // script for YUI initialization
pathToRoot,
pageData = this.adapter && this.adapter.page && this.adapter.page.data,
- pageRoutes = this.adapter && this.adapter.page && this.adapter.page.routes,
+ pageRoutes = this.adapter && this.adapter.page && this.adapter.page.clientRoutes,
updateLoaderCount = store._updateLoaderCount,
loaderRess,
lang = this.ac.context.lang;
View
@@ -107,7 +107,7 @@ module.exports = {
The `command` should be attached to the request.
@protected
- @method handleRequest
+ @method handleRequest
@param {http.ServerRequest} req
@param {Object} req.command the mojito command to be executed
@param {http.ServerResponse} res
@@ -135,17 +135,21 @@ module.exports = {
outputHandler.setLogger({ log: Y.log });
- // storing the static app config as well as contextualized
+ // storing the static app config as well as contextualized
// app config per request
outputHandler.page.staticAppConfig = appConfig;
outputHandler.page.appConfig = store.getAppConfig(context);
// - routes are not contextualized anymore
if (!CACHE.routes) {
CACHE.routes = app.getRouteMap();
+ CACHE.clientRoutes = app.getRouteMap({
+ client: true
+ });
}
outputHandler.page.routes = CACHE.routes;
+ outputHandler.page.clientRoutes = CACHE.clientRoutes;
// HookSystem::StartBlock
// enabling perf group
View
@@ -18,7 +18,7 @@ Example usage:
app = express();
- app.use(mojito.middleware());
+ app.use(mojito.middleware());
...
// or specify app specific paths (preferred)
app.mojito.attachRoutes(libpath.join(__dirname, 'config', 'routes.json'));
@@ -70,7 +70,7 @@ function readConfigYCB(fullPath) {
/**
Normalizes the `routes.json` configuration.
-@param {String} name
+@param {String} name
@param {Object} route the route object from `routes.json`
@return {Object} normalized route object
**/
@@ -162,6 +162,9 @@ module.exports = {
function registerRoutes(routes) {
Object.keys(routes).forEach(function (name) {
var route = routes[name];
+ route.annotations = route.annotations || {};
+ route.annotations.client = route.annotations.client !== false;
+ app.annotate(route.path, route.annotations);
Object.keys(route.verbs).forEach(function (verb) {
debug('[%s %s] installing handler', route.call, route.path);
verb = verb.toLowerCase();
@@ -20,7 +20,7 @@ YUI().use('mojito-deploy-addon', 'test', 'json-parse', function(Y) {
setUp: function() {
addon = new Y.mojito.addons.ac.deploy(
{instance: {}}, // command
- {page: { routes: { 'get': { } } } } // adapter
+ {page: { clientRoutes: { 'get': { } } } } // adapter
);
addon.ac = {
http: {
@@ -69,7 +69,8 @@ YUI().use('test', function (Y) {
// mock expect 'routes01.json'
root: ''
}
- }
+ },
+ annotate: function () {}
};
router._app = app;
},

0 comments on commit 471631f

Please sign in to comment.