import { getCache, setCache } from "#server/utils/context"; import { listCategories } from "../../service/category"; export default defineWrappedResponseHandler(async () => { const cacheKey = "categories:tree"; const cached = await getCache(cacheKey); if (cached) return R.success(cached); const tree = await listCategories(); await setCache(cacheKey, tree, 120); return R.success(tree); });