wip but I need to sleep
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { prisma } from "./db/db";
|
||||
import { Elysia, t } from "elysia";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { simpleApi } from "./games/simple";
|
||||
|
||||
const api = new Elysia({ prefix: "/api" })
|
||||
// [wip]
|
||||
@@ -30,31 +31,7 @@ const api = new Elysia({ prefix: "/api" })
|
||||
},
|
||||
})
|
||||
)
|
||||
.use(simpleApi);
|
||||
|
||||
.get("/gameState/:gameId", ({ params: { gameId } }) =>
|
||||
prisma.instance
|
||||
.findUnique({
|
||||
where: {
|
||||
id: Number(gameId),
|
||||
},
|
||||
})
|
||||
.then((game) => game?.gameState)
|
||||
)
|
||||
|
||||
.put(
|
||||
"/gameState/:gameId",
|
||||
({ params: { gameId }, body: { gameState } }) =>
|
||||
prisma.instance.update({
|
||||
data: { gameState },
|
||||
where: {
|
||||
id: Number(gameId),
|
||||
},
|
||||
}),
|
||||
{
|
||||
body: t.Object({
|
||||
gameState: t.Any(),
|
||||
}),
|
||||
}
|
||||
);
|
||||
export default api;
|
||||
export type Api = typeof api;
|
||||
|
||||
Reference in New Issue
Block a user