import { parse } from "jsr:@std/jsonc"; import * as z from "npm:zod"; // configure these from the config.jsonc file (you can use config.jsonc.example as reference) export const indexTarget = z.string().refine( (val) => { const parts = val.split("#"); if (parts.length !== 2) return false; const [prefix, suffix] = parts; const validPrefix = prefix === "user" || prefix.startsWith("did:web:"); const validSuffix = suffix === "skylite_index" || suffix === "bsky_appview"; return validPrefix && validSuffix; }, { message: "Each indexPriority entry must be in the form 'user#skylite_index', 'user#bsky_appview', 'did:web:...#skylite_index', or 'did:web:...#bsky_appview'", } ); const ConfigSchema = z.object({ jetstream: z.string(), spacedust: z.string(), constellation: z.string(), slingshot: z.string(), indexServer: z.object({ inviteOnly: z.boolean(), port: z.number(), did: z.string(), host: z.string(), }), viewServer: z.object({ inviteOnly: z.boolean(), port: z.number(), did: z.string(), host: z.string(), indexPriority: z.array(indexTarget), }), }); const raw = await Deno.readTextFile("config.jsonc"); const config = ConfigSchema.parse(parse(raw)); export { config };