import type { UpdatePlanLimitsInput } from '@gruperly/shared'; import { planSchema, UpdatePlanLimitsInputSchema } from '@gruperly/shared'; import { Hono } from 'hono'; import { z } from 'zod'; import type { BackendEnv } from '@/http/env'; import { problemJson, resultJson, unauthorizedProblem } from '@/http/problem-details'; import { validate } from '@/http/validate'; import { UpdatePlanLimits } from './use-case'; const route = new Hono(); route.put( '/plans/:plan/limits', validate.param(z.object({ plan: planSchema })), validate.json(UpdatePlanLimitsInputSchema), async (c) => { const user = c.get('user'); if (!user) return problemJson(c, unauthorizedProblem(c.req.path)); const { plan } = c.req.valid('param'); const input = c.req.valid('json') as UpdatePlanLimitsInput; const result = await new UpdatePlanLimits().execute(plan, input, user.id); return resultJson(c, result); }, ); export default route;