Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda