work on db

This commit is contained in:
dylan 2024-03-31 16:41:29 -07:00
parent 0d97f40fc5
commit 8b987bc589
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,13 @@
DROP TABLE repos;
DROP TABLE releases;
CREATE TABLE releases (
id text,
picobook_version int,
repo text,
slug text,
version text,
carts json,
title text,
);

View File

@ -1,4 +1,5 @@
import { Type } from "@sinclair/typebox";
import { TypeCompiler } from "@sinclair/typebox/compiler";
import { FirRouteInput, FirRouteOptions } from "../util/routewrap";
import {git} from "../util/git.ts";
import { randomUUID } from "crypto";
@ -13,9 +14,26 @@ const url = "/api/release";
const payloadT = Type.Any();
const manifestT = Type.Object({
picobook_version: Type.Number(),
id: Type.String(),
version: Type.String(),
carts: Type.Array(Type.String()),
repo: Type.String(),
title: Type.Optional(Type.String()),
author: Type.Optional(Type.String()),
readme: Type.Optional(Type.String()),
});
const ManifestType = TypeCompiler.Compile(manifestT)
const handler = async ({payload}: FirRouteInput<typeof payloadT>) => {
const {manifest, token} = payload;
if (!ManifestType.Check(manifest)) {
return false;
}
const uuid = randomUUID();
const repoPath = path.join(reposPath, uuid);