Medium
Which architectural approach is most recommended for injecting business services into Express controllers to ensure testability and decoupling?
Author: WeLoveDevsStatus: PublishedQuestion passed 2 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!
0
What is the main function of the `req.fresh` property in an Express application?0
When designing an Express API, why is it recommended to position logging middleware before request body parsing middleware?0
What architectural strategy should be adopted to handle a CPU-intensive task without blocking the Express event loop?0
When is the callback defined by app.param('id', ...) executed in Express?0
What critical vulnerability does this code present?
```
app.get('/download/:file', (req, res) => {
// Le nom du fichier est directement injecté depuis l'URL
const filePath = path.join(__dirname, 'uploads', req.params.file);
res.sendFile(filePath);
});
```0
What is the fundamental difference between req.path and req.originalUrl in an application using sub-applications or mounted routers?0
What is displayed in the console during a GET request to '/data'?
```
app.get('/data', (req, res, next) => {
console.log('1');
next('route');
}, (req, res) => {
console.log('2');
});
app.get('/data', (req, res) => {
console.log('3');
res.end();
});
```