From 09ac7e15f6068c70a628444efdc1e8709984598d Mon Sep 17 00:00:00 2001 From: Ken Powers Date: Thu, 29 Jun 2023 09:53:01 -0400 Subject: [PATCH 1/6] Make APIRoute generic like APIContext --- packages/astro/src/@types/astro.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index c544fd8b8c84..4c54fd82ff32 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1772,8 +1772,8 @@ export interface EndpointOutput { encoding?: BufferEncoding; } -export type APIRoute = ( - context: APIContext +export type APIRoute = Record> = ( + context: APIContext ) => EndpointOutput | Response | Promise; export interface EndpointHandler { From c71c4e65658c9cc6711ab94a407008f29b8b49dd Mon Sep 17 00:00:00 2001 From: Ken Powers Date: Thu, 29 Jun 2023 10:35:07 -0400 Subject: [PATCH 2/6] Use non-conflicting naming --- packages/astro/src/@types/astro.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 4c54fd82ff32..1860177b4446 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1772,8 +1772,8 @@ export interface EndpointOutput { encoding?: BufferEncoding; } -export type APIRoute = Record> = ( - context: APIContext +export type APIRoute = ( + context: APIContext ) => EndpointOutput | Response | Promise; export interface EndpointHandler { From ff9783e984244be357aea5e5e7e0bcf97452a699 Mon Sep 17 00:00:00 2001 From: Ken Powers Date: Fri, 30 Jun 2023 10:38:27 -0400 Subject: [PATCH 3/6] Revert "Use non-conflicting naming" This reverts commit c71c4e65658c9cc6711ab94a407008f29b8b49dd. --- packages/astro/src/@types/astro.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 1860177b4446..4c54fd82ff32 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1772,8 +1772,8 @@ export interface EndpointOutput { encoding?: BufferEncoding; } -export type APIRoute = ( - context: APIContext +export type APIRoute = Record> = ( + context: APIContext ) => EndpointOutput | Response | Promise; export interface EndpointHandler { From 61af58efdae71430c378a1b69196042e7741987e Mon Sep 17 00:00:00 2001 From: Ken Powers Date: Fri, 30 Jun 2023 10:39:23 -0400 Subject: [PATCH 4/6] Move Props --- packages/astro/src/@types/astro.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 4c54fd82ff32..7d7a045792f1 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1765,8 +1765,6 @@ export interface APIContext = Record; - export interface EndpointOutput { body: Body; encoding?: BufferEncoding; @@ -1780,6 +1778,8 @@ export interface EndpointHandler { [method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response); } +export type Props = Record; + export interface AstroRenderer { /** Name of the renderer. */ name: string; From 1d2bd60ec667cc0e210e0ff6bfd6c4c6358d23a2 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 3 Jul 2023 15:55:45 +0800 Subject: [PATCH 5/6] Add changeset --- .changeset/grumpy-readers-draw.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/grumpy-readers-draw.md diff --git a/.changeset/grumpy-readers-draw.md b/.changeset/grumpy-readers-draw.md new file mode 100644 index 000000000000..27ef7d0f3377 --- /dev/null +++ b/.changeset/grumpy-readers-draw.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Add `Prop` generic for `APIRoute` type From 3db6cb4a181a703b65a33f614dd69dd194558348 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 3 Jul 2023 15:58:10 +0800 Subject: [PATCH 6/6] Update grumpy-readers-draw.md --- .changeset/grumpy-readers-draw.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/grumpy-readers-draw.md b/.changeset/grumpy-readers-draw.md index 27ef7d0f3377..32156bc8b81e 100644 --- a/.changeset/grumpy-readers-draw.md +++ b/.changeset/grumpy-readers-draw.md @@ -2,4 +2,4 @@ "astro": patch --- -Add `Prop` generic for `APIRoute` type +Add `Props` generic for `APIRoute` type