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 6677441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:07:13+00:00 2026-05-26T04:07:13+00:00

Is there a common convention for breaking up and modularizing the app.js file in

  • 0

Is there a common convention for breaking up and modularizing the app.js file in an Express.js application? Or is it common to keep everything in a single file?

  • 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-05-26T04:07:14+00:00Added an answer on May 26, 2026 at 4:07 am

    I have mine broken up as follows:

    ~/app
    |~controllers
    | |-monkey.js
    | |-zoo.js
    |~models
    | |-monkey.js
    | |-zoo.js
    |~views
    | |~zoos
    |   |-new.jade
    |   |-_form.jade
    |~test
    |  |~controllers
    |    |-zoo.js
    |  |~models
    |    |-zoo.js
    |-index.js
    

    I use Exports to return what’s relevant. For instance, in the models I do:

    module.exports = mongoose.model('PhoneNumber', PhoneNumberSchema);
    

    and then if I need to create a phone number, it’s as simple as:

    var PhoneNumber = require('../models/phoneNumber');
    var phoneNumber = new PhoneNumber();
    

    if I need to use the schema, then PhoneNumber.schema

    (which assumes that we are working from the routes folder and need to go 1 level up and then down to models)


    EDIT 4

    The express wiki has a list of frameworks built on top of it.

    Of those, I think Twitter’s matador is structured pretty well. We actually used a very similar approach to how they load up parts of the app.

    derby.js also looks extremely interesting. It’s akin to meteor without all of the hype and actually gives credit where credit is due (notably, node and express).


    EDIT 3

    If you are a fan of CoffeeScript (I am not) and reeeeaaaaaally want the L&F of Rails, there is also Tower.js.


    EDIT 2

    If you are familiar with Rails and don’t mind the bleed-over of some concepts there is Locomotive. It is a light-weight framework built on Express. It has a very similar structure as RoR and carries over some of the more rudimentary concepts (such as routing).

    It’s worth checking out even if you don’t plan to use it.


    EDIT 1

    nodejs-express-mongoose-demo is very similar to how I have mine structured. Check it out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a common way to express the usage of arguments in C++? I
Are there any Common Lisp implementations for .Net?
Is there a common way to get the current time in or with milliseconds?
Is there a common standard for reporting errors in your class functions? I've seen
Is there a common interface in Python that I could derive from to modify
Evening, Is there a common or standardised name given to a function or method
There's a common way to store multiple values in one variable, by using a
There is a common feature of modern browsers where a user can select some
Throughout our site there's a common model, let's say Video, that has a number
Does anyone know if there is a common javascript library to enable scrolling that

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.