index.ts — astro Source File
Architecture documentation for index.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8926f54f_62e0_3440_f1c0_4e9da6cce27f["index.ts"] d44bf569_36b0_df5d_cf6a_ab8eca8d428d["astro:actions"] 8926f54f_62e0_3440_f1c0_4e9da6cce27f --> d44bf569_36b0_df5d_cf6a_ab8eca8d428d 82c23b20_84b3_3038_cd30_be2e0f2ef654["zod"] 8926f54f_62e0_3440_f1c0_4e9da6cce27f --> 82c23b20_84b3_3038_cd30_be2e0f2ef654 style 8926f54f_62e0_3440_f1c0_4e9da6cce27f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { defineAction } from 'astro:actions';
import { z } from 'astro/zod';
export const server = {
addToCart: defineAction({
accept: 'form',
input: z.object({ productId: z.string() }),
handler: async (input, context) => {
const cart: Array<string> = (await context.session.get('cart')) || [];
cart.push(input.productId);
await context.session.set('cart', cart);
return { cart, message: 'Product added to cart at ' + new Date().toTimeString() };
},
}),
getCart: defineAction({
handler: async (input, context) => {
return await context.session.get('cart');
},
}),
clearCart: defineAction({
accept: 'json',
handler: async (input, context) => {
await context.session.set('cart', []);
return { cart: [], message: 'Cart cleared at ' + new Date().toTimeString() };
},
}),
addUrl: defineAction({
input: z.object({ favoriteUrl: z.string().url() }),
handler: async (input, context) => {
const previousFavoriteUrl = await context.session.get<URL>('favoriteUrl');
const url = new URL(input.favoriteUrl);
context.session.set('favoriteUrl', url);
return { message: 'Favorite URL set to ' + url.href + ' from ' + (previousFavoriteUrl?.href ?? "nothing") };
}
})
}
Dependencies
- astro:actions
- zod
Source
Frequently Asked Questions
What does index.ts do?
index.ts is a source file in the astro codebase, written in typescript.
What does index.ts depend on?
index.ts imports 2 module(s): astro:actions, zod.
Where is index.ts in the architecture?
index.ts is located at packages/integrations/netlify/test/functions/fixtures/sessions/src/actions/index.ts (directory: packages/integrations/netlify/test/functions/fixtures/sessions/src/actions).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free