Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8369303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:36:29+00:00 2026-06-09T13:36:29+00:00

I’m new in the world of Node.js According to this topic: What is Node.js’

  • 0

I’m new in the world of Node.js

According to this topic: What is Node.js’ Connect, Express and “middleware”?
I learned that Connect was part of Express

I dug a little in the code, 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 invoke them correctly.

As far, in the ./myProject/app.js, that’s what I do:

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 clumsy, and what about my others files?

e.g., here is one of my routes:

myResources = app.resource(
                'myresources',
                require('./routes/myresources.js'));

and here is the content of myresources.js:

exports.index = function(req, res)
{
  res.render('./myresources.jade', { title: 'My Resources' });
};

exports.show = function(req, res)
{
  fonction resourceIsWellFormatted(param)
  {
    // Here is some code to determine whether the resource requested
    // match with the required format or not
    // return true if the format is ok
    // return false if not
  }

  if (resourceIsWellFormatted(req.params['myresources']))
  {
    // render the resource
  }
  else
  {
    res.send(400); // HEY! what about the nice Connect.badRequest in its utils.js?
  }
};

As you can see in the comment after the res.send(400), I ask myself if it is possible to use the badRequest function which is in the utils.js file of the Connect module.

What about the nice md5 function in the same file?

Do I have to place this hugly call at the start of my myresources.js to use them?:

var connectUtils =
      require('../node_modules/express/node_modules/connect/lib/utils.js');

or, is there a more elegant solution (even for the app.js)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:36:30+00:00Added an answer on June 9, 2026 at 1:36 pm

    the only more elegant way i came up with is (assuming express is inside your root “node_modules” folder):

    require("express/node_modules/connect/lib/utils");
    

    the node installation is on windows, node version 0.8.2


    and a bit of extra information:

    this way you don’t need to know where you are in the path and be forced to use relative paths (./ or ../), this can be done on any file nesting level.

    i put all my custom modules inside the root “node_modules” folder (i named my folder “custom_modules”) and call them this way at any level of nesting:

    require("custom_modules/mymodule/something")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I know there's a lot of other questions out there that deal with this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.