Add schema utils

This commit is contained in:
Jamie Kyle 2024-10-02 12:03:10 -07:00 committed by GitHub
parent c8a729f8be
commit b26466e59d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 674 additions and 151 deletions

View file

@ -9,6 +9,7 @@ import LRU from 'lru-cache';
import type { OptionalResourceService } from './OptionalResourceService';
import { SignalService as Proto } from '../ts/protobuf';
import { parseUnknown } from '../ts/util/schemas';
const MANIFEST_PATH = join(__dirname, '..', 'build', 'jumbomoji.json');
@ -64,8 +65,9 @@ export class EmojiService {
public static async create(
resourceService: OptionalResourceService
): Promise<EmojiService> {
const json = await readFile(MANIFEST_PATH, 'utf8');
const manifest = manifestSchema.parse(JSON.parse(json));
const contents = await readFile(MANIFEST_PATH, 'utf8');
const json: unknown = JSON.parse(contents);
const manifest = parseUnknown(manifestSchema, json);
return new EmojiService(resourceService, manifest);
}