From 156afc6ba5e9ab406ef167aa318baea18e60b51c Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Thu, 10 Jul 2025 14:08:31 +0200 Subject: Cleanup type errors --- src/pages/api/counter.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/pages/api') diff --git a/src/pages/api/counter.ts b/src/pages/api/counter.ts index 4f42236..d6d3134 100644 --- a/src/pages/api/counter.ts +++ b/src/pages/api/counter.ts @@ -1,11 +1,9 @@ import type { APIRoute } from 'astro'; -interface Env { - COUNTER_DO: DurableObjectNamespace; -} +const getEnv = (locals: any) => (locals as any).runtime.env as Env; export const GET: APIRoute = async ({ locals }) => { - const env = locals.runtime.env as Env; + const env = getEnv(locals); const id = env.COUNTER_DO.idFromName('counter'); const stub = env.COUNTER_DO.get(id); const response = await stub.fetch('https://counter.do/get'); @@ -13,7 +11,7 @@ export const GET: APIRoute = async ({ locals }) => { }; export const POST: APIRoute = async ({ locals }) => { - const env = locals.runtime.env as Env; + const env = getEnv(locals); const id = env.COUNTER_DO.idFromName('counter'); const stub = env.COUNTER_DO.get(id); const response = await stub.fetch('https://counter.do/increment'); -- cgit v1.3.1