Home / File/ middleware.js — astro Source File

middleware.js — astro Source File

Architecture documentation for middleware.js, a javascript file in the astro codebase. 2 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  d6cdf5cf_222a_f7c8_e325_2da474778078["middleware.js"]
  28099856_58cd_3901_dd91_085b361c6444["astro:i18n"]
  d6cdf5cf_222a_f7c8_e325_2da474778078 --> 28099856_58cd_3901_dd91_085b361c6444
  3a7a7ff7_6c64_95f9_af85_4deb518834f1["astro:middleware"]
  d6cdf5cf_222a_f7c8_e325_2da474778078 --> 3a7a7ff7_6c64_95f9_af85_4deb518834f1
  style d6cdf5cf_222a_f7c8_e325_2da474778078 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { middleware } from 'astro:i18n';
import { defineMiddleware, sequence } from 'astro:middleware';

const customLogic = defineMiddleware(async (context, next) => {
	const url = new URL(context.request.url);
	if (url.pathname.startsWith('/about')) {
		return new Response('ABOUT ME', {
			status: 200,
		});
	}

	const response = await next();

	return response;
});

export const onRequest = sequence(
	customLogic,
	middleware({
		prefixDefaultLocale: true,
		redirectToDefaultLocale: true,
		fallbackType: "rewrite"
	})
);

Subdomains

Functions

Dependencies

  • astro:i18n
  • astro:middleware

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 1 function(s): customLogic.
What does middleware.js depend on?
middleware.js imports 2 module(s): astro:i18n, astro:middleware.
Where is middleware.js in the architecture?
middleware.js is located at packages/astro/test/fixtures/i18n-routing-manual-with-default-middleware/src/middleware.js (domain: IntegrationAdapters, subdomain: SsrAdapters, directory: packages/astro/test/fixtures/i18n-routing-manual-with-default-middleware/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free