index.ts — astro Source File
Architecture documentation for index.ts, a typescript file in the astro codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 539f677c_93c9_1e05_dcf8_dd470043a1a3["index.ts"] 0dff10e7_1ebb_867f_8463_a5e280d1ba90["../actions/utils.js"] 539f677c_93c9_1e05_dcf8_dd470043a1a3 --> 0dff10e7_1ebb_867f_8463_a5e280d1ba90 826cd871_9abe_6942_9f87_963e3fcce533["../i18n/utils.js"] 539f677c_93c9_1e05_dcf8_dd470043a1a3 --> 826cd871_9abe_6942_9f87_963e3fcce533 135a8084_d596_67c2_9209_cca6693604e6["../types/public/common.js"] 539f677c_93c9_1e05_dcf8_dd470043a1a3 --> 135a8084_d596_67c2_9209_cca6693604e6 28857b9f_4720_3f29_4abb_a7eec34dcca5["../types/public/context.js"] 539f677c_93c9_1e05_dcf8_dd470043a1a3 --> 28857b9f_4720_3f29_4abb_a7eec34dcca5 7216d952_4e4a_2d18_a85b_74b4ace79e2b["../core/constants.js"] 539f677c_93c9_1e05_dcf8_dd470043a1a3 --> 7216d952_4e4a_2d18_a85b_74b4ace79e2b 34cf60ae_d0fa_22a9_892d_8834050ac3c1["../core/cookies/index.js"] 539f677c_93c9_1e05_dcf8_dd470043a1a3 --> 34cf60ae_d0fa_22a9_892d_8834050ac3c1 ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"] 539f677c_93c9_1e05_dcf8_dd470043a1a3 --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9 4f33d5b6_8fc0_380e_bc17_d17ec413fba7["../routing/request.js"] 539f677c_93c9_1e05_dcf8_dd470043a1a3 --> 4f33d5b6_8fc0_380e_bc17_d17ec413fba7 99bef061_4ac1_91d4_947d_810691aafb80["../core/routing/rewrite.js"] 539f677c_93c9_1e05_dcf8_dd470043a1a3 --> 99bef061_4ac1_91d4_947d_810691aafb80 920bd9c1_82bb_349b_649b_6be2001a6ea0["./sequence.js"] 539f677c_93c9_1e05_dcf8_dd470043a1a3 --> 920bd9c1_82bb_349b_649b_6be2001a6ea0 style 539f677c_93c9_1e05_dcf8_dd470043a1a3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { createCallAction, createGetActionResult } from '../../actions/utils.js';
import {
computeCurrentLocale,
computePreferredLocale,
computePreferredLocaleList,
} from '../../i18n/utils.js';
import type { Params, RewritePayload } from '../../types/public/common.js';
import type { APIContext } from '../../types/public/context.js';
import { ASTRO_GENERATOR } from '../constants.js';
import { AstroCookies } from '../cookies/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { getClientIpAddress } from '../routing/request.js';
import { getOriginPathname } from '../routing/rewrite.js';
import { sequence } from './sequence.js';
/**
* Payload for creating a context to be passed to Astro middleware
*/
export type CreateContext = {
/**
* The incoming request
*/
request: Request;
/**
* Optional parameters
*/
params?: Params;
/**
* A list of locales that are supported by the user
*/
userDefinedLocales?: string[];
/**
* User defined default locale
*/
defaultLocale: string;
/**
* Initial value of the locals
*/
locals?: App.Locals;
};
/**
* Creates a context to be passed to Astro middleware `onRequest` function.
*/
function createContext({
request,
params = {},
userDefinedLocales = [],
defaultLocale = '',
locals = {},
}: CreateContext): APIContext {
let preferredLocale: string | undefined = undefined;
let preferredLocaleList: string[] | undefined = undefined;
let currentLocale: string | undefined = undefined;
let clientIpAddress: string | undefined;
const url = new URL(request.url);
const route = url.pathname;
// ... (140 more lines)
Domain
Subdomains
Types
Dependencies
- ../actions/utils.js
- ../core/constants.js
- ../core/cookies/index.js
- ../core/errors/index.js
- ../core/routing/rewrite.js
- ../i18n/utils.js
- ../routing/request.js
- ../types/public/common.js
- ../types/public/context.js
- ./sequence.js
Source
Frequently Asked Questions
What does index.ts do?
index.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in index.ts?
index.ts defines 4 function(s): createContext, isLocalsSerializable, isPlainObject, trySerializeLocals.
What does index.ts depend on?
index.ts imports 10 module(s): ../actions/utils.js, ../core/constants.js, ../core/cookies/index.js, ../core/errors/index.js, ../core/routing/rewrite.js, ../i18n/utils.js, ../routing/request.js, ../types/public/common.js, and 2 more.
Where is index.ts in the architecture?
index.ts is located at packages/astro/src/core/middleware/index.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/astro/src/core/middleware).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free