Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
Best folder structure in expressJs with socketIO

What is best folder structure for a project that includes:

  • 2 database (mongodb, influxdb)
  • socket io ...
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It all depends on the personal preferences. Make your folder structure the way you are most comfortable working with.

For example, I love my code to be split in submodules or simply said to be in different directories, accordingly to the job the code is used for.

I'd personally go with a couple of folders:

.{src}
├── controllers                # All controller operations according the routes are stored here
│   ├── authController.ts      # Handles authentication requests
│   ├── usersController.ts     # Handles users route requests
│   └── ...
│
├── database                   # All database connections are stored here. For example you have two databases
│   ├── db.ts                  # Initialize DB connection
│   └── ...
│
├── middleware
│   ├── authenticated.ts       # Decode and verify JWT token
│   ├── error.ts               # Common Error Handler
│   ├── logger.ts              # Control logging levels
│   └── ...
│
├── models                     # Simple descriptor of the database tables
│   ├── usersModel.ts          # DB model for users
│   └── ...
│
├── schema                     # Schemas that are used for CRUD operations with the models
│   ├── users.ts               # DB Schema for users
│   └── ...
│
├── listeners
│   ├── socketsManager.ts      # Socket listeners/emitters handle
│   └── ...
│
├── app.ts                     # Entry file for the project
├── .env                       # Store environment variables
├── routes.ts                  # All routes initializer
└── ...

Although, you might not like the naming or the order I've put on, you can create your own one you feel comfortable with. Another thing you might do is take a look at some conventions that are up on the internet or some of the most popular projects like frameworks.

It's all depending on your needs and what you feel comfortable working with, after all.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!