Home / Function/ GET() — astro Function Reference

GET() — astro Function Reference

Architecture documentation for the GET() function in streaming.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  065665d2_699c_f7b0_ec98_f2308f5a0ab0["GET()"]
  e40b8693_9ff9_8053_c4d2_09fc6c578d15["streaming.ts"]
  065665d2_699c_f7b0_ec98_f2308f5a0ab0 -->|defined in| e40b8693_9ff9_8053_c4d2_09fc6c578d15
  style 065665d2_699c_f7b0_ec98_f2308f5a0ab0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/node/test/fixtures/api-route/src/pages/streaming.ts lines 1–22

export const GET = ({ locals }) => {
    let sentChunks = 0;

    const readableStream = new ReadableStream({
        async pull(controller) {
            if (sentChunks === 3) return controller.close();
            else sentChunks++;

            await new Promise(resolve => setTimeout(resolve, 1000));
            controller.enqueue(new TextEncoder().encode('hello\n'));
        },
        cancel() {
            locals.cancelledByTheServer = true;
        }
    });

    return new Response(readableStream, {
        headers: {
            "Content-Type": "text/event-stream"
        }
    });
}

Domain

Subdomains

Frequently Asked Questions

What does GET() do?
GET() is a function in the astro codebase, defined in packages/integrations/node/test/fixtures/api-route/src/pages/streaming.ts.
Where is GET() defined?
GET() is defined in packages/integrations/node/test/fixtures/api-route/src/pages/streaming.ts at line 1.

Analyze Your Own Codebase

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

Try Supermodel Free