nl_tokens: Function : route This replacements for the route function of Backbone . Router ensures that each route defined in the router is added to the Express . JS app .
pl_tokens: function route ( routeUri ) { debug ( 'route `%s`' , routeUri ) ; var self = this , Barefoot = require ( '../' ) ( ) ; // Lazy-Load the barefoot objects CookieAdapter and DataStore. Otherwise // we'd have some cyclic dependency problems. CookieAdapter = Barefoot . CookieAdapter ; DataStore = Barefoot . DataStore ; return self . app . get ( '/' + routeUri , function ( req , res ) { debug ( 'request to `/%s`' , routeUri ) ; var callback = self [ self . routes [ routeUri ] ] , cookieAdapter = new CookieAdapter ( { cookies : req . cookies } ) , dataStore = new DataStore ( ) ; // Ensure that request-local stuff is available locally: self . req = req ; self . res = res ; self . cookieAdapter = cookieAdapter ; self . dataStore = dataStore ; // Ensure the request context is set up locally: if ( ! _ . isUndefined ( self . setupRequestContext ) ) { self . setupRequestContext . call ( self ) ; } // Ensure that the APIAdapter has access to the current request: if ( ! _ . isUndefined ( self . apiAdapter ) ) { self . apiAdapter . req = req ; } // Execute the route: var routeResult = callback . apply ( <mask> , _ . values ( req . params ) ) ; // Ensure cookies are placed inside the response: res . cookies = self . cookieAdapter . cookies ; return routeResult ; } ) ; }