You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

12 lines
406 B

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);
});