Skip to content

Commit

Permalink
add type to worker-openapi template endpoints handle function (#6248)
Browse files Browse the repository at this point in the history
  • Loading branch information
rwv authored Jul 25, 2024
1 parent 28723a2 commit 271832a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion templates/worker-openapi/src/endpoints/taskCreate.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -34,7 +35,7 @@ export class TaskCreate extends OpenAPIRoute {
},
};

async handle(c) {
async handle(c: Context) {
// Get validated data
const data = await this.getValidatedData<typeof this.schema>();

Expand Down
3 changes: 2 additions & 1 deletion templates/worker-openapi/src/endpoints/taskDelete.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -30,7 +31,7 @@ export class TaskDelete extends OpenAPIRoute {
},
};

async handle(c) {
async handle(c: Context) {
// Get validated data
const data = await this.getValidatedData<typeof this.schema>();

Expand Down
3 changes: 2 additions & 1 deletion templates/worker-openapi/src/endpoints/taskFetch.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -43,7 +44,7 @@ export class TaskFetch extends OpenAPIRoute {
},
};

async handle(c) {
async handle(c: Context) {
// Get validated data
const data = await this.getValidatedData<typeof this.schema>();

Expand Down
3 changes: 2 additions & 1 deletion templates/worker-openapi/src/endpoints/taskList.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -37,7 +38,7 @@ export class TaskList extends OpenAPIRoute {
},
};

async handle(c) {
async handle(c: Context) {
// Get validated data
const data = await this.getValidatedData<typeof this.schema>();

Expand Down

0 comments on commit 271832a

Please sign in to comment.