I am new to the world of Node.js
According to this topic: What is Node.js' Connect, Express and "middleware"?
I found out Connect was part of Express
I dug up the code a bit and I found two very interesting files:
./myProject/node_modules/express/lib/utils.js
and better:
./myProject/node_modules/express/node_modules/connect/lib/utils.js
These two files are full of useful functions, and I was wondering how to call them correctly.
So far in ./myProject/app.jswhat I am doing:
var express = require('express')
, resource = require('express-resource')
, mongoose = require('mongoose')
, expresstUtils =
require('./node_modules/express/lib/utils.js');
, connectUtils =
require('./node_modules/express/node_modules/connect/lib/utils.js');
But I found it a little awkward, but what about the files of others?
for example, here is one of my routes:
myResources = app.resource(
'myresources',
require('./routes/myresources.js'));
and here is the content myresources.js:
exports.index = function(req, res)
{
res.render('./myresources.jade', { title: 'My Resources' });
};
exports.show = function(req, res)
{
fonction resourceIsWellFormatted(param)
{
}
if (resourceIsWellFormatted(req.params['myresources']))
{
}
else
{
res.send(400);
}
};
As you can see in the comment after res.send(400), I ask myself if it is possible to use the function badRequestthat is in utils.jsthe Connect module file .
md5 ?
myresources.js, ?:
var connectUtils =
require('../node_modules/express/node_modules/connect/lib/utils.js');
, ( app.js)?
!