lets fuckin go

This commit is contained in:
2025-08-07 22:44:19 -04:00
parent a90a914d2f
commit 9d4b17b762
18 changed files with 271 additions and 49 deletions

View File

@@ -3,7 +3,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
<script type="module" src="/src/entry-client.tsx"></script>
<script type="module" src="/src/app.tsx"></script>
</head>
<body>
<div id="app" />

View File

@@ -8,6 +8,7 @@
},
"dependencies": {
"@solidjs/router": "^0.15.3",
"hono": "^4.8.12",
"solid-js": "^1.9.5"
},
"devDependencies": {

View File

@@ -0,0 +1,4 @@
import { hc } from "hono/client";
import { type ApiType } from "../../server/src/api";
export default hc<ApiType>("http://localhost:5001/api");

View File

@@ -1,7 +1,9 @@
import "./app.css";
import "./style.css";
import { Route, Router } from "@solidjs/router";
import { Suspense } from "solid-js";
import { lazy, Suspense } from "solid-js";
import pkg from "../package.json";
import { render } from "solid-js/web";
import Root from "./routes/index";
const Version = () => (
<div class="full free clear">
@@ -19,17 +21,21 @@ const Version = () => (
</div>
);
export default function App() {
return (
<Router
root={(props) => (
<>
<Suspense>{props.children}</Suspense>
<Version />
</>
)}
>
<Route path="/" component={() => "tesingt"} />
</Router>
);
}
const App = () => (
<Router
root={(props) => (
<>
<Suspense>{props.children}</Suspense>
<Version />
</>
)}
>
<Route path="/" component={lazy(() => import("./routes/index"))} />
<Route
path="/:game"
component={lazy(() => import("./routes/[game]/index"))}
/>
</Router>
);
render(App, document.getElementById("app")!);

View File

@@ -1,4 +0,0 @@
import App from "./app";
import { render } from "solid-js/web";
render(App, document.getElementById("app")!);

View File

@@ -1,14 +1,19 @@
import { A } from "@solidjs/router";
import { createResource, For } from "solid-js";
import { createEffect, createResource, For } from "solid-js";
import * as Games from "../db/Games";
import api from "../api";
export default () => {
const [games] = createResource(() => Games.queryAll());
const [ping] = createResource(async () =>
api.ping.$get().then(async (res) => await res.text())
);
return (
<div style={{ padding: "20px" }}>
<For each={games()}>
{ping()}
{/* <For each={games()}>
{(game) => <A href={`/${game.name}`}>{game.name}</A>}
</For>
</For> */}
</div>
);
};

View File

@@ -1,11 +0,0 @@
To install dependencies:
```sh
bun install
```
To run:
```sh
bun run dev
```
open http://localhost:3000

View File

@@ -0,0 +1,19 @@
-- CreateTable
CREATE TABLE "Game" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"name" TEXT NOT NULL,
"rules" TEXT
);
-- CreateTable
CREATE TABLE "Instance" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"gameId" INTEGER NOT NULL,
"gameState" JSONB NOT NULL,
CONSTRAINT "Instance_gameId_fkey" FOREIGN KEY ("gameId") REFERENCES "Game" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "Game_name_key" ON "Game"("name");

View File

@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "sqlite"

View File

@@ -0,0 +1,24 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
model Game {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String @unique
rules String?
instances Instance[]
}
model Instance {
id Int @id @default(autoincrement())
gameId Int
game Game @relation(fields: [gameId], references: [id])
gameState Json
}

View File

@@ -1,18 +1,20 @@
{
"name": "server",
"scripts": {
"dev": "NODE_ENV=development bun run --hot --port 5001 src/index.ts",
"start": "NODE_ENV=production bun run --port 5001 src/index.ts",
"dev": "concurrently 'pnpm run devserver' 'pnpm run dbstudio'",
"devserver": "NODE_ENV=development bun run --hot --port 5001 src/index.ts",
"dbstudio": "pnpm dlx prisma studio --browser none",
"dbdeploy": "pnpm dlx prisma migrate deploy",
"dbsync": "concurrently 'pnpm dlx prisma generate' 'pnpm dlx prisma migrate dev'"
"dbsync": "concurrently 'pnpm dlx prisma generate' 'pnpm dlx prisma migrate dev'",
"start": "NODE_ENV=production bun run --port 5001 src/index.ts"
},
"dependencies": {
"hono": "^4.8.12",
"@prisma/client": "6.13.0"
"@prisma/client": "6.13.0",
"hono": "^4.8.12"
},
"devDependencies": {
"@types/bun": "latest",
"concurrently": "^9.2.0",
"prisma": "6.13.0"
}
}

View File

@@ -0,0 +1,6 @@
import path from "node:path";
import { defineConfig } from "prisma/config";
export default defineConfig({
schema: path.join("db", "schema.prisma"),
});

View File

@@ -0,0 +1,6 @@
import { Hono } from "hono";
const api = new Hono().get("/ping", (c) => c.text("pong"));
export default api;
export type ApiType = typeof api;

View File

@@ -1,7 +1,15 @@
import { Hono } from "hono";
import { serveStatic } from "hono/bun";
import api from "./api";
import { cors } from "hono/cors";
const app = new Hono();
app.use("*", async (c, next) => {
console.log(c.req.method, c.req.url);
await next();
console.log(">>", c.res.status);
});
const isDev = Bun.env.NODE_ENV === "development";
const isProd = Bun.env.NODE_ENV === "production";
@@ -13,4 +21,7 @@ isProd &&
})
);
app.use("*", cors());
app.route("/api", api);
export default app;

View File

@@ -1,7 +1,8 @@
{
"compilerOptions": {
"strict": true,
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx"
}
}
"compilerOptions": {
"strict": true,
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx",
"esModuleInterop": true
}
}