Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

229
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda