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

154
Vistas
Putting all the imports in index file

I'm working on a node/express project and I'm wondering if it's better to put all the imports of the dependencies in the index file of a controller and then pass them as parameters to the function or each function should have its required dependencies - screenshot of controller's files

import passport from 'passport';
import jwt from 'jsonwebtoken';
import crypto from 'crypto';
import util from 'util';
import httpStatusCodes from '../../utils/httpStatusCodes.js';
import * as login from './login.controller.js';
import logout from './logout.controller.js';
import * as reserPasswordController from './reset-password.controller.js';
import { ErrorHandler } from '../../utils/errorsHandler.js';
import responseHandler from '../../utils/responseHandler.js';
import signupUser from './signup.controller.js';
import addressService from '../../services/address.services.js';
import * as emailVerificationController from './email-verification.controller.js';
import generateCode from '../../utils/codeGenerator.js';
import sendMail from '../../utils/sendEmail.js';
import verifyEmailTemplate from '../../utils/verifyEmailTemplate.js';
import crudHandler from '../../services/crudHandler.js';

const randomBytesAsync = util.promisify(crypto.randomBytes);

const signin = (req, res, next) => {
  const secret = process.env.TOKEN_SECRET;
  login.login({
    req,
    res,
    next,
    passport,
    ErrorHandler,
    httpStatusCodes,
    responseHandler,
    jwt,
    secret,
  });
};

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think it's better to put all the dependencies in the index file. However, I'm not 100% sure of that, and I don't think it really matters, just whichever you feel like doing and works out best for you.

about 4 years ago · Juan Pablo Isaza 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