"use node";
import { v } from "convex/values";
import { internal } from "./_generated/api";
import { action, internalAction } from "./_generated/server";
// Action - orchestrates everything
export const fetchCharacter = action({
args: {
id: v.number(),
},
handler: async (ctx, { id }) => {
// First, check if it exists
const existing = await ctx.runQuery(internal.character.getCharacter, {
id,
});
if (existing) {
return existing;
}
//if not fetch
},
});
if in the handler i put the return existing the type definition become any otherwise its normal