Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!