Home / File/ cookies.ts — astro Source File

cookies.ts — astro Source File

Architecture documentation for cookies.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 2 imports 2 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  b5fc2880_5111_4957_5d79_b9e1839f86d6["cookies.ts"]
  ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"]
  b5fc2880_5111_4957_5d79_b9e1839f86d6 --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9
  28a532e7_212b_2efa_9bc7_16bacf6d5bab["cookie"]
  b5fc2880_5111_4957_5d79_b9e1839f86d6 --> 28a532e7_212b_2efa_9bc7_16bacf6d5bab
  style b5fc2880_5111_4957_5d79_b9e1839f86d6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { SerializeOptions } from 'cookie';
import { parse, serialize } from 'cookie';
import { AstroError, AstroErrorData } from '../errors/index.js';

export type AstroCookieSetOptions = Pick<
	SerializeOptions,
	| 'domain'
	| 'path'
	| 'expires'
	| 'maxAge'
	| 'httpOnly'
	| 'sameSite'
	| 'secure'
	| 'encode'
	| 'partitioned'
>;

export interface AstroCookieGetOptions {
	decode?: (value: string) => string;
}

type AstroCookieDeleteOptions = Omit<AstroCookieSetOptions, 'expires' | 'maxAge' | 'encode'>;

interface AstroCookieInterface {
	value: string;
	json(): Record<string, any>;
	number(): number;
	boolean(): boolean;
}

interface AstroCookiesInterface {
	get(key: string): AstroCookieInterface | undefined;
	has(key: string): boolean;
	set(
		key: string,
		value: string | number | boolean | Record<string, any>,
		options?: AstroCookieSetOptions,
	): void;
	delete(key: string, options?: AstroCookieDeleteOptions): void;
}

const DELETED_EXPIRATION = new Date(0);
const DELETED_VALUE = 'deleted';
const responseSentSymbol = Symbol.for('astro.responseSent');

const identity = (value: string) => value;

class AstroCookie implements AstroCookieInterface {
	constructor(public value: string) {}
	json() {
		if (this.value === undefined) {
			throw new Error(`Cannot convert undefined to an object.`);
		}
		return JSON.parse(this.value);
	}
	number() {
		return Number(this.value);
	}
	boolean() {
		if (this.value === 'false') return false;
// ... (220 more lines)

Domain

Subdomains

Functions

Dependencies

  • ../core/errors/index.js
  • cookie

Frequently Asked Questions

What does cookies.ts do?
cookies.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in cookies.ts?
cookies.ts defines 2 function(s): identity, value.
What does cookies.ts depend on?
cookies.ts imports 2 module(s): ../core/errors/index.js, cookie.
Where is cookies.ts in the architecture?
cookies.ts is located at packages/astro/src/core/cookies/cookies.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/core/cookies).

Analyze Your Own Codebase

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

Try Supermodel Free