diff --git a/convex/_generated/api.d.ts b/convex/_generated/api.d.ts index 4f430be..4f841d4 100644 --- a/convex/_generated/api.d.ts +++ b/convex/_generated/api.d.ts @@ -19,6 +19,7 @@ import type * as auth from "../auth.js"; import type * as constants from "../constants.js"; import type * as games from "../games.js"; import type * as http from "../http.js"; +import type * as init from "../init.js"; import type * as maps from "../maps.js"; import type * as openai from "../openai.js"; import type * as results from "../results.js"; @@ -38,6 +39,7 @@ declare const fullApi: ApiFromModules<{ constants: typeof constants; games: typeof games; http: typeof http; + init: typeof init; maps: typeof maps; openai: typeof openai; results: typeof results; diff --git a/convex/init.ts b/convex/init.ts new file mode 100644 index 0000000..85ae729 --- /dev/null +++ b/convex/init.ts @@ -0,0 +1,10 @@ +import { internalMutation } from "./_generated/server"; +import { seedMaps } from "./maps"; + +export default internalMutation({ + handler: async (ctx) => { + const maps = await ctx.db.query("maps").first(); + if (maps) return; + await seedMaps(ctx, {}); + }, +}); diff --git a/package.json b/package.json index 840730f..8af9657 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,10 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "npm-run-all --parallel dev:frontend dev:backend", + "dev": "npm-run-all dev:init --parallel dev:frontend dev:backend", "dev:frontend": "next dev", "dev:backend": "convex dev", + "dev:init": "convex dev --run init --until-success", "predev": "convex dev --until-success && node setup.mjs --once && convex dashboard", "build": "next build", "start": "next start",