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

173
Visualizações
How to add JOI validator to firebase function?

How to add JOI validator to firebase function as a middleware? I call firebase function like below:

exports.createUserAccount = region("europe-east1").https.onCall(createAccount); // createAccount is an function

in normal endpoints/routes in express i do something like this:

app.post("/app/some/endpoint", auth(), validator(), createAccount());

where my validator is an Joi middleware where I check that req.body is correct like a provided schema.

PS. I don't have an (req, res) in createAccount function, cause firebase return provided in this function an simple dto.

Thanks for any help

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use JOI middlewares on Firebase by exposing an Express app via HTTP triggered functions and via Callable functions.

onRequest and onCall both takes a function that will return a Promise. Starting from here, you can create an Express application, register any middleware you want, then pass the Express app to the onCall.

The way to create the Express app is greatly documented here. Note that there is a big difference between onRequest and onCall:

  • onRequest expose the whole Express app, so you can register routes and so on, and build a REST API using it;
  • onCall will wrap your Express app, because the SDK calls it with a POST request. It means you'll have to only accept one request on your Express app, mapping it to the root path and expecting a POST request.
about 4 years ago · Juan Pablo Isaza 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