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

135
Vistas
Is it possible to shorten the code even further?

I am a lover of beautiful and short code, and here a problem arises ... short of course, but not beautiful. Can this code be made more beautiful?

app.post('/xsolla/', (req, res) => new Xsolla(req, res));

tried this option but it didn't work😅

app.post('/xsolla/', new Xsolla);
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

One option is to use rest parameters instead of repeating them:

app.post('/xsolla/', (...args) => new Xsolla(...args));

But keep in mind that readable code is more important than short code.

Reflect.construct (in combination with .bind) would almost do the trick for removing the need to list arguments altogether, but unfortunately it takes the arguments to be passed to the constructor as an array in the second argument, rather than as separate items in the argument list.

about 4 years ago · Juan Pablo Isaza Denunciar

0

If you were doing this in multiple places and just wanted to avoid repeated code, you could make yourself a reusable request handler:

function xHandler(req, res) {
    new Xsolla(req, res);
}

app.post('/xsolla/', xHandler);
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