From 271832a45ad92cc41b859a7c2698857ae78a9e9c Mon Sep 17 00:00:00 2001 From: rwv <7891383+rwv@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:32:06 +0800 Subject: [PATCH] add type to worker-openapi template endpoints handle function (#6248) --- templates/worker-openapi/src/endpoints/taskCreate.ts | 3 ++- templates/worker-openapi/src/endpoints/taskDelete.ts | 3 ++- templates/worker-openapi/src/endpoints/taskFetch.ts | 3 ++- templates/worker-openapi/src/endpoints/taskList.ts | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/templates/worker-openapi/src/endpoints/taskCreate.ts b/templates/worker-openapi/src/endpoints/taskCreate.ts index 798aa82ceddb..047da669f722 100644 --- a/templates/worker-openapi/src/endpoints/taskCreate.ts +++ b/templates/worker-openapi/src/endpoints/taskCreate.ts @@ -1,6 +1,7 @@ import { Bool, OpenAPIRoute } from "chanfana"; import { z } from "zod"; import { Task } from "../types"; +import type { Context } from "hono"; export class TaskCreate extends OpenAPIRoute { schema = { @@ -34,7 +35,7 @@ export class TaskCreate extends OpenAPIRoute { }, }; - async handle(c) { + async handle(c: Context) { // Get validated data const data = await this.getValidatedData(); diff --git a/templates/worker-openapi/src/endpoints/taskDelete.ts b/templates/worker-openapi/src/endpoints/taskDelete.ts index ed6f691e78eb..00ef62a6676d 100644 --- a/templates/worker-openapi/src/endpoints/taskDelete.ts +++ b/templates/worker-openapi/src/endpoints/taskDelete.ts @@ -1,6 +1,7 @@ import { Bool, OpenAPIRoute, Str } from "chanfana"; import { z } from "zod"; import { Task } from "../types"; +import type { Context } from "hono"; export class TaskDelete extends OpenAPIRoute { schema = { @@ -30,7 +31,7 @@ export class TaskDelete extends OpenAPIRoute { }, }; - async handle(c) { + async handle(c: Context) { // Get validated data const data = await this.getValidatedData(); diff --git a/templates/worker-openapi/src/endpoints/taskFetch.ts b/templates/worker-openapi/src/endpoints/taskFetch.ts index 7d032ea1d2bf..8c76f031d447 100644 --- a/templates/worker-openapi/src/endpoints/taskFetch.ts +++ b/templates/worker-openapi/src/endpoints/taskFetch.ts @@ -1,6 +1,7 @@ import { Bool, OpenAPIRoute, Str } from "chanfana"; import { z } from "zod"; import { Task } from "../types"; +import type { Context } from "hono"; export class TaskFetch extends OpenAPIRoute { schema = { @@ -43,7 +44,7 @@ export class TaskFetch extends OpenAPIRoute { }, }; - async handle(c) { + async handle(c: Context) { // Get validated data const data = await this.getValidatedData(); diff --git a/templates/worker-openapi/src/endpoints/taskList.ts b/templates/worker-openapi/src/endpoints/taskList.ts index 8f50506e085d..26f30f6e7843 100644 --- a/templates/worker-openapi/src/endpoints/taskList.ts +++ b/templates/worker-openapi/src/endpoints/taskList.ts @@ -1,6 +1,7 @@ import { Bool, Num, OpenAPIRoute } from "chanfana"; import { z } from "zod"; import { Task } from "../types"; +import type { Context } from "hono"; export class TaskList extends OpenAPIRoute { schema = { @@ -37,7 +38,7 @@ export class TaskList extends OpenAPIRoute { }, }; - async handle(c) { + async handle(c: Context) { // Get validated data const data = await this.getValidatedData();