19 lines
564 B
TypeScript
19 lines
564 B
TypeScript
import type { AppContext } from '@/types/hono';
|
|
import type { AdminUpdatePlanInput } from '@repo/api-contract';
|
|
import { updatePlan } from './update-plan.business';
|
|
|
|
type UpdatePlanParams = { code: string };
|
|
|
|
export async function updatePlanHandler(c: AppContext) {
|
|
const { code } = c.req.valid('param' as never) as UpdatePlanParams;
|
|
const body = c.req.valid('json' as never) as AdminUpdatePlanInput;
|
|
|
|
const result = await updatePlan(code, body);
|
|
|
|
if (!result.ok) {
|
|
return c.json({ message: result.message }, 404);
|
|
}
|
|
|
|
return c.json(result.data);
|
|
}
|