Strongly typed config (and ts strict mode)

This commit is contained in:
Linnea Gräf 2025-02-22 16:06:44 +01:00
parent 36c05556e5
commit 4585f60af7
No known key found for this signature in database
GPG key ID: AA563E93EB628D91
7 changed files with 31 additions and 16 deletions

11
src/config.ts Normal file
View file

@ -0,0 +1,11 @@
import rawconfig from "../config.json" with {type: "json"};
import {z} from 'zod';
const configT = z.object({
token: z.string(),
listenbrainzAccount: z.string(),
gitapi: z.string(),
});
export type Config = z.infer<typeof configT>;
export const config: Config = configT.parse(rawconfig);