Allowing using middleware config in dev server options
- Lingua principale
- TypeScript
- Stelle
- 27k
- Fork
- 11.8k
- Merge medio
- 14h 23m
- PR unite (30g)
- 162
Descrizione
### Command
serve
### Description
Dev server middleware configuration is very commonly used in development,such as auto login or log printing,but it is not currently supported。
### Describe the solution you'd like
Refer to the implementation of proxyConfig, add the middlewareConfig configuration to angular.json -> server -> options, and parse and inject the middleware in angular/build.
middlewareConfig supports configuring a js file path, and the file exports a single middleware function or an array of multipe middleware functions. such as:
```
function log(req, res, next) {
next()
}
module.exports = log;
```
```
function log(req, res, next) {
next()
}
function auth(req, res, next) {
next()
}
module.exports =
[
log,
auth,
]
```
### Describe alternatives you've considered
_No response_
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start by tracing the serve command's dev-server options and the existing proxyConfig implementation, then inspect how angular.json server options are parsed and how angular/build injects development-server configuration. Done means middlewareConfig accepts a JavaScript file exporting one middleware function or an array, and the configured middleware runs in the dev server.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript
- Ambito
- build-system, cli
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100