Home / Function/ constructor() — astro Function Reference

constructor() — astro Function Reference

Architecture documentation for the constructor() function in runtime.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  41e87dd5_f04f_80e3_ba9e_0d578121251a["constructor()"]
  91969197_292d_3b15_21c6_0e876968e961["AstroSession"]
  41e87dd5_f04f_80e3_ba9e_0d578121251a -->|defined in| 91969197_292d_3b15_21c6_0e876968e961
  style 41e87dd5_f04f_80e3_ba9e_0d578121251a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/session/runtime.ts lines 67–110

	constructor({
		cookies,
		config,
		runtimeMode,
		driverFactory,
		mockStorage,
	}: {
		cookies: AstroCookies;
		config: SSRManifestSession | undefined;
		runtimeMode: RuntimeMode;
		driverFactory: SessionDriverFactory | null;
		mockStorage: Storage | null;
	}) {
		if (!config) {
			throw new AstroError({
				...SessionStorageInitError,
				message: SessionStorageInitError.message(
					'No driver was defined in the session configuration and the adapter did not provide a default driver.',
				),
			});
		}
		this.#cookies = cookies;
		this.#driverFactory = driverFactory;
		const { cookie: cookieConfig = DEFAULT_COOKIE_NAME, ...configRest } = config;
		let cookieConfigObject: AstroCookieSetOptions | undefined;
		if (typeof cookieConfig === 'object') {
			const { name = DEFAULT_COOKIE_NAME, ...rest } = cookieConfig;
			this.#cookieName = name;
			cookieConfigObject = rest;
		} else {
			this.#cookieName = cookieConfig || DEFAULT_COOKIE_NAME;
		}
		this.#cookieConfig = {
			sameSite: 'lax',
			secure: runtimeMode === 'production',
			path: '/',
			...cookieConfigObject,
			httpOnly: true,
		};
		this.#config = configRest;
		if (mockStorage) {
			this.#storage = mockStorage;
		}
	}

Domain

Subdomains

Frequently Asked Questions

What does constructor() do?
constructor() is a function in the astro codebase, defined in packages/astro/src/core/session/runtime.ts.
Where is constructor() defined?
constructor() is defined in packages/astro/src/core/session/runtime.ts at line 67.

Analyze Your Own Codebase

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

Try Supermodel Free