Access to Express app object
See original GitHub issueFeature Request
Is your feature request related to a problem? Please describe.
I’m writing a probot app that has a few custom Express routes, and I want access to the Express app
object to call things such as app.set('trust proxy', true)
Describe the solution you’d like
app.express
, maybe?
Describe alternatives you’ve considered Currently I hack my way around it with this code:
const v0 = app.route('/api/v0');
v0.use((req, res, next) => {
req.app.set('trust proxy', true);
next();
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
What's the best way to access the express 'app' object from ...
You can simply access app by req.app in your route handlers.
Read more >How to use the app object in Express.js | by John Au-Yeung
The app object is the core object of an Express app. It has the methods to let us add middleware and route handlers....
Read more >API Reference - Express 4.x
The app object conventionally denotes the Express application. ... You can access local variables in templates rendered within the application.
Read more >How To Use the req Object in Express - DigitalOcean
Learn about using the req object in Express.js projects to examine calls from the client side, make HTTP requests, and handle incoming data ......
Read more >Express/Node introduction - Learn web development | MDN
This object, which is traditionally named app , has methods for routing HTTP requests, configuring middleware, rendering HTML views, registering ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This sorta worked for me, but it makes my app a bit clunky (if I had written the app to begin with knowing the above it might’ve been better, but pivoting now is proving to be too difficult) - since I now know it’s possible, I guess this issue can be closed. Still, it would be nice to have (probot’s)
app
expose either the backing express app or at least expose some of these methods (set
,get
,use
, andengine
come to mind as useful methods to expose)Anyways, just a thought - please feel free to close this if this isn’t a feature you think is worth adding
Yeah, I was totally wrong. So, you can get to the underlying express server but its a bit of a hassle at the moment. Probot works by calling
probot run
, a CLI tool that loads up your code as a function after its done all of its setup. You can instead take a programmatic approach and control the entrypoint yourself:That I know works 😁.