Compare commits

...

9 Commits

Author SHA1 Message Date
dylan
281cc0dda7 Update todos 2024-04-02 08:42:38 -07:00
dylan
03ea59c7e3 Merge branch 'main' into dev 2024-03-31 18:06:11 -07:00
dylan
f17578af17 register getRelease route 2024-03-31 17:59:12 -07:00
dylan
e5039232c8 extra wrapping so not json array in db 2024-03-31 17:57:23 -07:00
dylan
a3b07d6028 created_at -> timestamp 2024-03-31 17:49:50 -07:00
dylan
008e5777c5 await the insertion 2024-03-31 17:44:52 -07:00
dylan
7fec78ff84 stringify json? 2024-03-31 17:42:07 -07:00
dylan
b37d5933a7 oops, wrong table name 2024-03-31 17:38:14 -07:00
dylan
c7d4ffa9dd oops, missing comma 2024-03-31 17:36:55 -07:00
5 changed files with 30 additions and 12 deletions

View File

@@ -4,8 +4,12 @@
- [x] Add version prop to picobook.json
- [x] "Compile" carts in server
- [x] Save compiled carts to db
- [ ] Load cart by URL in React
- [ ] Update GH Workflow to be by push
- [x] Load cart by URL in React
- [x] Update GH Workflow to be by push
## Next
- [ ] Fix css bug on chromium
- [ ] Add user page to show all projects
## Later
- [ ] Update pico console handle
@@ -14,6 +18,7 @@
- [ ] More console support (touch detected, gamepad count, etc.)
- [ ] User accounts to manage published games, and user accounts for players to save progress
- [ ] GPIO Support (maybe gpio prop in picobook.json can have values like "ignore" | "v1")
- [ ] Persistent cart data
## GPIO ideas
- RGB background color

View File

@@ -0,0 +1,2 @@
ALTER TABLE releases DROP COLUMN created_at;
ALTER TABLE releases ADD created_at timestamp;

View File

@@ -38,7 +38,7 @@ const handler = async ({payload}: FirRouteInput<typeof payloadT>) => {
const carts = await getCarts(repoPath, manifest.carts);
insertRelease({
await insertRelease({
manifest,
carts,
});

View File

@@ -1,9 +1,7 @@
// Database Access Layer stuff goes here
// Database Access Layer stuff goes here
import { v4 as uuidv4 } from 'uuid';
import { db, sql } from "../../database/db"
import { JsonValue } from '@firebox/tsutil';
import { db, sql } from "../../database/db";
import { PicobookManifest } from '../types';
export type DbRelease = {
@@ -16,6 +14,16 @@ export type DbRelease = {
manifest: PicobookManifest;
}
export type DbReleaseInternal = {
id: string;
slug: string;
repo: string;
version: string;
carts: {carts: {name: string; rom: number[]}[]};
author: string;
manifest: PicobookManifest;
}
const compareVersions = (a: string, b: string) => {
const [a1, a2] = a.split(".").map(x => Number(x));
const [b1, b2] = b.split(".").map(x => Number(x));
@@ -34,24 +42,24 @@ export const getReleases = async (where: {
version?: string;
}): Promise<DbRelease[]> => {
const {author, slug, version} = where;
let rows: DbReleaseInternal[];
if (!version) {
const rows = await db.query(sql`
rows = await db.query(sql`
SELECT * from releases
WHERE
slug = ${slug} AND
author = ${author}
`);
return rows;
} else {
const rows = await db.query(sql`
rows = await db.query(sql`
SELECT * from releases
WHERE
slug = ${slug} AND
author = ${author} AND
version = ${version}
`);
return rows;
}
return rows.map(row => ({...row, carts: row.carts.carts}));
}
export const getRelease = async (where: {
@@ -78,12 +86,13 @@ export const getRelease = async (where: {
export const insertRelease = async (props: {manifest: PicobookManifest, carts: {name: string; rom: number[]}[]}) => {
const {manifest, carts} = props;
// console.log('carts', JSON.stringify(carts));
const {id: slug, author, repo, version} = manifest;
const id = uuidv4();
const now = new Date();
await db.query(sql`
INSERT INTO chats (id, slug, repo, version, author, carts, manifest, created_at)
VALUES (${id}, ${slug}, ${repo}, ${version}, ${author} ${carts}, ${manifest}, ${now})
INSERT INTO releases (id, slug, repo, version, author, carts, manifest, created_at)
VALUES (${id}, ${slug}, ${repo}, ${version}, ${author}, ${{carts}}, ${manifest}, ${now})
`);
return id;
}

View File

@@ -1,4 +1,5 @@
import echo from "./api/echo.ts";
import getRelease from "./api/getRelease.ts";
import release from "./api/release.ts";
import webhook from "./api/webhook.ts";
@@ -6,6 +7,7 @@ export const routeList = [
echo,
webhook,
release,
getRelease,
];
export type RouteList = typeof routeList;