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

  • Home
  • SEARCH
  • 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 8479151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:56:41+00:00 2026-06-10T18:56:41+00:00

I have created an Express 2.x app using the CLI. So I have a

  • 0

I have created an Express 2.x app using the CLI. So I have a routes directory and an index.js.
Now, in app.js, I have connected to Redis, and it works properly.

I call the function in the routes/index.js file from app.js here:

app.post('/signup', routes.myroute);

The myroute function contains code to get a key from Redis.

Now, I get the error that redis is not defined.
How do I pass the redis object into routes/index.js from 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-10T18:56:42+00:00Added an answer on June 10, 2026 at 6:56 pm

    Easiest Solution

    You probably have a require() function that includes a redis lib in your app.js. Just take that line and add it to the top of your index.js file.

    if you are using the node_redis module, simply include this:

    var redis = require("redis"),
    client = redis.createClient();
    

    Alternative Approach

    If you are looking to reuse the existing connection, try passing the client variable to the function in index.js:

    app.js

    app.post('/signup', routes.myroute(client));
    

    index.js

    exports.myroute = function(client) {
        // client can be used here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In express, I have defined some routes app.post(/api/v1/client, Client.create); app.get(/api/v1/client, Client.get); ... I have
I have created an application in VS C# Express 2008 using Windows 7 as
Hey all, I have a linq app using C# express2008 and sqlserver express 2005
I have created a small app in C using WinAPI and I have a
I have a Node.js app using Express that stores data in a mongoDB (locally).
I have been using IIS express as my web server for awhile now, but
I have a userform in 2008 vb express edition. A part number is created
I have created an android application that calls (using kSOAP library) a SOAP based
I have noticed when one creates a project using Express.js, the route handler functions
I have created my site using ASP.NET Personal Starter Kits 3.5. I use Visual

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.