nl_tokens: Called when the server is created but before it starts to listening to incoming requests . N . B . gmeAuth safeStorage and workerManager are not ready to use until the start function is called . ( However inside an incoming request they are all ensured to have been initialized . )
pl_tokens: function initialize ( middlewareOpts ) { const logger = middlewareOpts . logger . fork ( 'BindingsDocs' ) , ensureAuthenticated = middlewareOpts . ensureAuthenticated ; function servePythonDocFile ( rootDir , fileName , res , logger ) { const options = { root : rootDir , dotfiles : 'deny' , headers : { 'x-timestamp' : Date . now ( ) , 'x-sent' : true } } ; res . sendFile ( fileName , options , function ( err ) { if ( err ) { logger . error ( 'Failed to send ' + fileName , err ) ; res . status ( err . status ) . end ( ) ; } } ) ; } // Ensure authenticated can be used only after this rule. router . use ( '*' , function ( req , res , next ) { res . setHeader ( 'X-WebGME-Media-Type' , 'webgme.v1' ) ; next ( ) ; } ) ; // Use ensureAuthenticated if the routes require authentication. (Can be set explicitly for each route.) router . <mask> ( '*' , ensureAuthenticated ) ; function getFullUrl ( req , name ) { return req . protocol + '://' + req . headers . host + middlewareOpts . getMountedPath ( req ) + req . baseUrl + name ; } router . get ( '/' , function ( req , res ) { res . json ( { python : getFullUrl ( req , '/python/index.html' ) } ) ; } ) ; router . get ( '/python/' , function ( req , res ) { servePythonDocFile ( PYTHON_DOCS_DIR , 'index.html' , res , logger ) ; } ) ; router . get ( '/python/*' , function ( req , res ) { servePythonDocFile ( PYTHON_DOCS_DIR , req . params [ 0 ] , res , logger ) ; } ) ; }