angular / angular/angular-cli

Allowing using middleware config in dev server options

Ouverte
#32,811 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
angular/build:dev-server area: @angular/build gemini-triaged
Langage dominant
TypeScript
Étoiles
27k
Forks
11.8k
Merge moyen
14 h 23 min
PR mergées (30 j)
162

Description

### 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_

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
build-system, cli
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
52/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.