lets fuckin go
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
To install dependencies:
|
||||
```sh
|
||||
bun install
|
||||
```
|
||||
|
||||
To run:
|
||||
```sh
|
||||
bun run dev
|
||||
```
|
||||
|
||||
open http://localhost:3000
|
||||
@@ -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");
|
||||
3
packages/server/db/migrations/migration_lock.toml
Normal file
3
packages/server/db/migrations/migration_lock.toml
Normal 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"
|
||||
24
packages/server/db/schema.prisma
Normal file
24
packages/server/db/schema.prisma
Normal 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
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
6
packages/server/prisma.config.ts
Normal file
6
packages/server/prisma.config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import path from "node:path";
|
||||
import { defineConfig } from "prisma/config";
|
||||
|
||||
export default defineConfig({
|
||||
schema: path.join("db", "schema.prisma"),
|
||||
});
|
||||
6
packages/server/src/api.ts
Normal file
6
packages/server/src/api.ts
Normal 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;
|
||||
@@ -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;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "hono/jsx"
|
||||
}
|
||||
}
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "hono/jsx",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user