firebase / firebase/firebase-tools

Mismatch between documentation and implementation of Express framework

Open
#5,832 4 comments 0 reactions 1 assignee Claimed by @jamesdaniels View on GitHub
integration: web frameworks type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

The documentation says we can export an `app` factory function with the signature `() => Express`:

https://github.com/firebase/firebase-tools/blob/56fb8a34201ab903f92178f696bc3b28acfb79bb/src/frameworks/docs/express.md?plain=1#L151-L160

But the implementation assumes that `app` is an `Express` instance, not a factory function.

https://github.com/firebase/firebase-tools/blob/56fb8a34201ab903f92178f696bc3b28acfb79bb/src/frameworks/express/index.ts#L70-L82

I believe the fix would be simply:
```diff
if (typeof app === "function") {
try {
const express = app();
if (typeof express.render === "function") {
return (
bootstrapScript +
- ";\nexports.handle = async (req, res) => (await bootstrap).app(req, res);"
+ "const express = (await bootstrap).app();" +
+ ";\nexports.handle = async (req, res) => express.handle(req, res);"
);
}
} catch (e) {
// continue, failure here is expected
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.