Back
Version 4
3/6/2024
import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
import ky from "npm:ky";
import * as v from "npm:valibot";
const ValSchema = v.object({
id: v.uuid(),
author: v.object({
id: v.uuid(),
username: v.string(),
}),
name: v.string(),
code: v.string(),
version: v.integer(),
createdAt: v.coerce(v.date(), (d) => new Date(d)),
readme: v.string(),
likeCount: v.integer(),
referenceCount: v.integer(),
});
export async function fetchVal(author: string, name: string) {
const prefixUrl = new URL(`${API_URL}/v1/alias`);
const val = await ky.get(`${author}/${name}`).json();
return v.parse(ValSchema, val);
}
Updated: March 30, 2024