feat: Update website, API, and infra (#164)

>Adds `maitred` in charge of handling automated game installs, updates,
and even execution.

>Not only that, we have the hosted stuff here
>- [x] AWS Task on ECS GPUs
>- [ ] Add a service to listen for game starts and stops
(docker-compose.yml)
>- [x] Add a queue for requesting a game to start
>- [x] Fix up the play/watch UI 

>TODO:
>- Add a README
>- Add an SST docs

Edit:

- This adds a new landing page, updates the homepage etc etc
>I forgot what the rest of the updated stuff are 😅
This commit is contained in:
Wanjohi
2025-02-11 12:26:35 +03:00
committed by GitHub
parent 93327bdf1a
commit 060718d8b0
139 changed files with 5814 additions and 5049 deletions

View File

@@ -1,151 +1,151 @@
import { z } from "zod"
import { fn } from "../utils";
import { Common } from "../common";
import { Examples } from "../examples";
import databaseClient from "../database"
import { id as createID } from "@instantdb/admin";
import { groupBy, map, pipe, values } from "remeda"
import { useCurrentDevice, useCurrentUser } from "../actor";
// import { z } from "zod"
// import { fn } from "../utils";
// import { Common } from "../common";
// import { Examples } from "../examples";
// import databaseClient from "../database"
// import { id as createID } from "@instantdb/admin";
// import { groupBy, map, pipe, values } from "remeda"
// import { useCurrentDevice, useCurrentUser } from "../actor";
export module Games {
export const Info = z
.object({
id: z.string().openapi({
description: Common.IdDescription,
example: Examples.Game.id,
}),
name: z.string().openapi({
description: "A human-readable name for the game, used for easy identification.",
example: Examples.Game.name,
}),
steamID: z.number().openapi({
description: "The Steam ID of the game, used to identify it during installation and runtime.",
example: Examples.Game.steamID,
})
})
.openapi({
ref: "Game",
description: "Represents a Steam game that can be installed and played on a machine.",
example: Examples.Game,
});
// export module Games {
// export const Info = z
// .object({
// id: z.string().openapi({
// description: Common.IdDescription,
// example: Examples.Game.id,
// }),
// name: z.string().openapi({
// description: "A human-readable name for the game, used for easy identification.",
// example: Examples.Game.name,
// }),
// steamID: z.number().openapi({
// description: "The Steam ID of the game, used to identify it during installation and runtime.",
// example: Examples.Game.steamID,
// })
// })
// .openapi({
// ref: "Game",
// description: "Represents a Steam game that can be installed and played on a machine.",
// example: Examples.Game,
// });
export type Info = z.infer<typeof Info>;
// export type Info = z.infer<typeof Info>;
export const create = fn(Info.pick({ name: true, steamID: true }), async (input) => {
const id = createID()
const db = databaseClient()
const device = useCurrentDevice()
// export const create = fn(Info.pick({ name: true, steamID: true }), async (input) => {
// const id = createID()
// const db = databaseClient()
// const device = useCurrentDevice()
await db.transact(
db.tx.games[id]!.update({
name: input.name,
steamID: input.steamID,
}).link({ machines: device.id })
)
// await db.transact(
// db.tx.games[id]!.update({
// name: input.name,
// steamID: input.steamID,
// }).link({ machines: device.id })
// )
// //
// return id
// })
return id
})
// export const list = async () => {
// const db = databaseClient()
// const user = useCurrentUser()
export const list = async () => {
const db = databaseClient()
const user = useCurrentUser()
// const query = {
// $users: {
// $: { where: { id: user.id } },
// games: {}
// },
// }
const query = {
$users: {
$: { where: { id: user.id } },
games: {}
},
}
// const res = await db.query(query)
const res = await db.query(query)
// const games = res.$users[0]?.games
// if (games && games.length > 0) {
// const result = pipe(
// games,
// groupBy(x => x.id),
// values(),
// map((group): Info => ({
// id: group[0].id,
// name: group[0].name,
// steamID: group[0].steamID,
// }))
// )
// return result
// }
// return null
// }
const games = res.$users[0]?.games
if (games && games.length > 0) {
const result = pipe(
games,
groupBy(x => x.id),
values(),
map((group): Info => ({
id: group[0].id,
name: group[0].name,
steamID: group[0].steamID,
}))
)
return result
}
return null
}
// export const fromSteamID = fn(z.number(), async (steamID) => {
// const db = databaseClient()
export const fromSteamID = fn(z.number(), async (steamID) => {
const db = databaseClient()
// const query = {
// games: {
// $: {
// where: {
// steamID,
// }
// }
// }
// }
const query = {
games: {
$: {
where: {
steamID,
}
}
}
}
// const res = await db.query(query)
const res = await db.query(query)
// const games = res.games
const games = res.games
// if (games.length > 0) {
// const result = pipe(
// games,
// groupBy(x => x.id),
// values(),
// map((group): Info => ({
// id: group[0].id,
// name: group[0].name,
// steamID: group[0].steamID,
// }))
// )
// return result[0]
// }
if (games.length > 0) {
const result = pipe(
games,
groupBy(x => x.id),
values(),
map((group): Info => ({
id: group[0].id,
name: group[0].name,
steamID: group[0].steamID,
}))
)
return result[0]
}
// return null
// })
return null
})
// export const linkToCurrentUser = fn(z.string(), async (steamID) => {
// const user = useCurrentUser()
// const db = databaseClient()
export const linkToCurrentUser = fn(z.string(), async (steamID) => {
const user = useCurrentUser()
const db = databaseClient()
// await db.transact(db.tx.games[steamID]!.link({ owners: user.id }))
await db.transact(db.tx.games[steamID]!.link({ owners: user.id }))
// return "ok"
// })
return "ok"
})
// export const unLinkFromCurrentUser = fn(z.number(), async (steamID) => {
// const user = useCurrentUser()
// const db = databaseClient()
export const unLinkFromCurrentUser = fn(z.number(), async (steamID) => {
const user = useCurrentUser()
const db = databaseClient()
// const query = {
// $users: {
// $: { where: { id: user.id } },
// games: {
// $: {
// where: {
// steamID,
// }
// }
// }
// },
// }
const query = {
$users: {
$: { where: { id: user.id } },
games: {
$: {
where: {
steamID,
}
}
}
},
}
// const res = await db.query(query)
// const games = res.$users[0]?.games
// if (games && games.length > 0) {
// const game = games[0] as Info
// await db.transact(db.tx.games[game.id]!.unlink({ owners: user.id }))
const res = await db.query(query)
const games = res.$users[0]?.games
if (games && games.length > 0) {
const game = games[0] as Info
await db.transact(db.tx.games[game.id]!.unlink({ owners: user.id }))
// return "ok"
// }
return "ok"
}
// return null
// })
return null
})
}
// }