middleware.js — astro Source File
Architecture documentation for middleware.js, a javascript file in the astro codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 0d2161c8_9cdf_64eb_c8ca_7aa4e135c503["middleware.js"] 3a7a7ff7_6c64_95f9_af85_4deb518834f1["astro:middleware"] 0d2161c8_9cdf_64eb_c8ca_7aa4e135c503 --> 3a7a7ff7_6c64_95f9_af85_4deb518834f1 style 0d2161c8_9cdf_64eb_c8ca_7aa4e135c503 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { defineMiddleware, sequence } from 'astro:middleware';
export const first = defineMiddleware(async (context, next)=> {
if (context.url.pathname === '/index2') {
return next('/123/post')
} else {
return next(`/destination`);
}
});
export const second = defineMiddleware(async (context, next)=> {
context.locals.pattern = context.routePattern;
return next();
});
export const onRequest = sequence(first, second);
Domain
Subdomains
Dependencies
- astro:middleware
Source
Frequently Asked Questions
What does middleware.js do?
middleware.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain, SsrAdapters subdomain.
What functions are defined in middleware.js?
middleware.js defines 2 function(s): first, second.
What does middleware.js depend on?
middleware.js imports 1 module(s): astro:middleware.
Where is middleware.js in the architecture?
middleware.js is located at packages/astro/test/fixtures/rewrite-route-pattern/src/middleware.js (domain: IntegrationAdapters, subdomain: SsrAdapters, directory: packages/astro/test/fixtures/rewrite-route-pattern/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free