Does firebase-functions need bodyParser?

1,179 views
Skip to first unread message

Naresh Bhatia

unread,
Aug 6, 2017, 9:36:29 PM8/6/17
to Firebase Google Group
I am creating my own express app and handing it over to firebase-functions as demonstrated in this functions sample:

const expressApp = express();

app.use(cors({ origin: true }));
// app.use(bodyParser.urlencoded({ extended: true }));
// app.use(bodyParser.json());
app.use(validateFirebaseIdToken);

expressApp.get('/books', getBooks);
expressApp.post('/books', createBook);

export const app = functions.https.onRequest(expressApp);

Usually in my express apps I use the bodyParser middleware to decode JSON bodies. Surprisingly, the app is working without this middleware (note the commented lines above). Also the functions samples don't include it. I am curious how firebase-functions manages to work without this middleware?

Thanks in advance.

Kato Richardson

unread,
Aug 7, 2017, 2:26:39 PM8/7/17
to Firebase Google Group
Hi Naresh,

Pretty sure Functions are just including the middleware (or an alternate parser) behind the scenes before passing it into your function. So no real magic happening here other than convenience. : )

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/32caa31d-42a9-4992-b7b7-ec5f5ff4c4ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages