node.js allowed app objects declaratively

  • Pseudo object form
= app function () { 
    the console.log ( " I am a subject initialized app " ); 
}; 

. app get = function () { 
   the console.log ( ' This is a get method of app ' ); 
}; 

app. post = function () { 
   the console.log ( ' this is a post method ' ); 
}; 

App (); 
app.post ();

Output

I initialize the app is a subject
which is a post method

  • An enhanced pseudo-objects
G = {};
 var App = function (REQ, RES) {
     IF (G [ ' Login ' ]) 
    { 
        G [ ' Login ' ] (REQ, RES); 
    } 
}; 

. App GET = function (urlinstring, the callback) { 
   G [urlinstring] = the callback; 
}; 
. App GET ( ' Login ' , function (req, res) { 
  // note, and where req res not http server and the corresponding request req and res corresponding to the console.log (
" this is the value of the parameter req login method used: " + req); the console.log ( ' the this IS A Module1 for Login ' ); }); the setTimeout (function () { App ( " Hey ~ ~ yo baby ginseng, very sharp Hey " , " ginseng Kingdom theme song " ); } 3000 ) ;

Output:

This is the value of the parameter req login method used: Hey baby yo ~ ~ ginseng, really clever hey
this is a module for login

Guess you like

Origin www.cnblogs.com/saintdingspage/p/11914442.html