Skip to content

Commit

Permalink
refactor(@angular/build): assign name to custom Vite middleware for b…
Browse files Browse the repository at this point in the history
…etter debugging

Naming the custom middleware improves the ability to identify middleware order during debugging.
  • Loading branch information
alan-agius4 committed Sep 13, 2024
1 parent 740c648 commit 902dbf3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function createAngularAssetsMiddleware(
outputFiles: AngularMemoryOutputFiles,
usedComponentStyles: Map<string, string[]>,
): Connect.NextHandleFunction {
return function (req, res, next) {
return function angularAssetsMiddleware(req, res, next) {
if (req.url === undefined || res.writableEnded) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import type { Connect, ViteDevServer } from 'vite';
* and passes control to the next middleware in the chain.
*/
export function createAngularHeadersMiddleware(server: ViteDevServer): Connect.NextHandleFunction {
return function (_req: Connect.IncomingMessage, res: ServerResponse, next: Connect.NextFunction) {
return function angularHeadersMiddleware(
_req: Connect.IncomingMessage,
res: ServerResponse,
next: Connect.NextFunction,
) {
const headers = server.config.server.headers;
if (!headers) {
return next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { lookupMimeTypeFromRequest } from '../utils';

export function angularHtmlFallbackMiddleware(
req: Connect.IncomingMessage,
res: ServerResponse,
_res: ServerResponse,
next: Connect.NextFunction,
): void {
// Similar to how it is handled in vite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function createAngularIndexHtmlMiddleware(
outputFiles: AngularMemoryOutputFiles,
indexHtmlTransformer: ((content: string) => Promise<string>) | undefined,
): Connect.NextHandleFunction {
return function (req, res, next) {
return function angularIndexHtmlMiddleware(req, res, next) {
if (!req.url) {
next();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export function createAngularSSRMiddleware(
): Connect.NextHandleFunction {
let cachedAngularServerApp: ReturnType<typeof getOrCreateAngularServerApp> | undefined;

return function (req: Connect.IncomingMessage, res: ServerResponse, next: Connect.NextFunction) {
return function angularSSRMiddleware(
req: Connect.IncomingMessage,
res: ServerResponse,
next: Connect.NextFunction,
) {
if (req.url === undefined) {
return next();
}
Expand Down

0 comments on commit 902dbf3

Please sign in to comment.