Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,21 @@ jobs:
name: Web
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
working-directory: web
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.2.2
- run: bun install --frozen-lockfile
working-directory: server
- run: bun install --frozen-lockfile
- run: bun run build
- run: cd web && bun run build
server:
name: Server
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
working-directory: server
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.2.2
- run: bun install --frozen-lockfile
- run: bun run build
- run: cd server && bun run build
507 changes: 507 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions common/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
11 changes: 11 additions & 0 deletions common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "common",
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
27 changes: 27 additions & 0 deletions common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,

// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,

// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,

// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"@biomejs/biome": "^1.9.4",
"lefthook": "^1.10.10"
},
"workspaces": ["common", "server", "web"],
"scripts": {
"prepare": "lefthook install",
"dev": "bun --env-file=./.env :dev",
Expand Down
4 changes: 2 additions & 2 deletions server/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Hono } from "hono";
import cors from "./middlewares/cors";
import hello from "./routes/hello";
import cors from "./middlewares/cors.ts";
import hello from "./routes/hello.ts";

const app = new Hono().use(cors("CORS_ALLOW_ORIGINS")).route("/", hello);

Expand Down
5 changes: 1 addition & 4 deletions server/lib/env.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { panic } from "common/lib/panic.ts";
import type { Context } from "hono";
import { env as hono_env } from "hono/adapter";

export function env(c: Context, name: string): string {
return hono_env(c)[name] ?? panic(`Environment variable not found: ${name}`);
}

export function panic(message: string): never {
throw new Error(message);
}
2 changes: 1 addition & 1 deletion server/middlewares/cors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Context, Next } from "hono";
import { cors as hono_cors } from "hono/cors";
import { env } from "../lib/env";
import { env } from "../lib/env.ts";

const cors = (env_var: string) => (c: Context, next: Next) =>
hono_cors({
Expand Down
5 changes: 4 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "server",
"type": "module",
"private": true,
"scripts": {
"dev": "bun run --env-file=../.env --hot index.ts",
"build": "bun tsc"
},
"dependencies": {
"hono": "^4.7.1"
"hono": "^4.7.1",
"common": "workspace:common"
},
"devDependencies": {
"typescript": "^5.7.3"
Expand Down
7 changes: 7 additions & 0 deletions web/lib/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { panic } from "common/lib/panic";

export function env(name: string): string {
return (
import.meta.env[name] ?? panic(`Environment variable not found: ${name}`)
);
}
3 changes: 2 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"hono": "^4.7.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"server": "file:../server"
"common": "workspace:common",
"server": "workspace:server"
},
"devDependencies": {
"@eslint/js": "^9.19.0",
Expand Down
3 changes: 2 additions & 1 deletion web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import reactLogo from "./assets/react.svg";
import "./App.css";
import { hc } from "hono/client";
import type { App as Server } from "server";
import { env } from "../lib/env";

const client = hc<Server>(import.meta.env.VITE_API_ENDPOINT);
const client = hc<Server>(env("VITE_API_ENDPOINT"));

function App() {
const [count, setCount] = useState(0);
Expand Down
2 changes: 1 addition & 1 deletion web/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "./index.css";
import { assert } from "common/lib/panic.ts";
import App from "./App.tsx";
import { assert } from "./lib/panic.ts";

const root = assert(document.getElementById("root"), "root not found");

Expand Down
2 changes: 1 addition & 1 deletion web/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
"include": ["src", "lib"]
}