Blog entry

Express JS

Express - node.js web application framework

expressjs.com/
Express is a minimal and flexible node.js web application framework, ... With a myriad of HTTP utility methods and Connect middleware at your disposal, ...

Checking out the Express.JS API Reference

A myriad of HTTP utility methods it says. Thinking about HTTP verbs and the syntax
app.get('/', function(req, res){
  res.send('hello world');
});


which is about all I really know at this point, let's dig in and see how Express
is put together to extend node.JS with a robust set of features.

app.routes

The app.routes object houses all of the routes defined mapped by the associated HTTP verb. This object may be used for introspection capabilities, for example Express uses this internally not only for routing but to provide default OPTIONS behaviour unless app.options() is used. Your application or framework may also remove routes by simply by removing them from this object.

console.log(app.routes) 

{ get:
  [ { path: '/',
  method: 'get',
  callbacks: [Object],
  keys: [ ],
  regexp: /^\/\/?$/i },
  { path: '/user/:id',
  method: 'get',
  callbacks: [Object],
  keys: [{ name: 'id', optional: false }],
  regexp: /^\/user\/(?:([^\/]+?))\/?$/i } ],
 delete:
  [ { path: '/user/:id',
  method: 'delete',
  callbacks: [Object],
  keys: [Object],
  regexp: /^\/user\/(?:([^\/]+?))\/?$/i } ] }
 
While I'm here I want to make a note on serving files from multiple directories because I think this is a good thing.
app.use(express.static(__dirname + '/public')); 
app.use(express.static(__dirname + '/files'));
app.use(express.static(__dirname + '/uploads'));
 

Share this: 

 

Support

Drupal professional support

 

Small Business Tools

You have a vision, but you need the tools. We have the tools.

 

Drupal Training

Let us show you as much or as little as you would like to learn.

 

Responsive Design

Responsive web design for mobile, smartphones, tablets and desktop PCs.

On the Subject of Me

On the Subject of Me

I'm Allison with many hats. I am a System Analyst and Technical Writer with an IT and programming background.

I think Drupal is a super-awesome framework and I'm happiest when working on a Drupal Project!

Hire me, I'm really good

Expansion packs

You can add features to your Starter Kit at any time. Powerful add-ons include:

My Photostream