refactor: remove type casting

This commit is contained in:
nafees nazik
2024-07-09 21:55:21 +05:30
parent 4fec8c6330
commit acc5da193a
3 changed files with 4 additions and 7 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
import { ErrorResponses } from "@/server/api/error";
import type { PublicAPI } from "@/server/api/hono";
import { createRoute, z } from "@hono/zod-openapi";
import type { Context } from "hono";
export const RequestSchema = z.object({
id: z
@@ -45,7 +44,7 @@ const route = createRoute({
},
});
const getOne = (app: PublicAPI) => {
app.openapi(route, (c: Context) => {
app.openapi(route, (c) => {
const params = c.req.param();
return c.json(
+2 -3
View File
@@ -2,10 +2,8 @@ import { withMemberAuth } from "@/server/api/auth";
import { ErrorResponses } from "@/server/api/error";
import type { PublicAPI } from "@/server/api/hono";
import { ApiCompanySchema } from "@/server/api/schema/company";
import { db } from "@/server/db";
import { createRoute, z } from "@hono/zod-openapi";
import type { Company } from "@prisma/client";
import type { Context } from "hono";
const route = createRoute({
method: "get",
@@ -26,7 +24,8 @@ const route = createRoute({
},
});
const getMany = (app: PublicAPI) => {
app.openapi(route, async (c: Context) => {
app.openapi(route, async (c) => {
const db = c.get("db");
const { membership } = await withMemberAuth(c);
const companyIds = membership.map((m) => m.companyId);
+1 -2
View File
@@ -3,7 +3,6 @@ import { ApiError, ErrorResponses } from "@/server/api/error";
import type { PublicAPI } from "@/server/api/hono";
import { ApiCompanySchema } from "@/server/api/schema/company";
import { createRoute, z } from "@hono/zod-openapi";
import type { Context } from "hono";
export const RequestSchema = z.object({
id: z
@@ -38,7 +37,7 @@ const route = createRoute({
},
});
const getOne = (app: PublicAPI) => {
app.openapi(route, async (c: Context) => {
app.openapi(route, async (c) => {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
const { company } = (await withCompanyAuth(c)) as { company: any };