Initial commit: ElysiaJS backend + TanStack Start frontend + Traefik compose

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
mane 2026-06-27 04:01:48 +00:00
commit a346cf3a5c
17 changed files with 505 additions and 0 deletions

4
backend/.dockerignore Normal file
View file

@ -0,0 +1,4 @@
node_modules
.git
.env
*.log

17
backend/Dockerfile Normal file
View file

@ -0,0 +1,17 @@
# --- Backend: ElysiaJS on Bun ---
FROM oven/bun:1.1-alpine AS deps
WORKDIR /app
COPY package.json bun.lock* ./
RUN bun install --production --frozen-lockfile || bun install --production
FROM oven/bun:1.1-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
COPY --from=deps /app/node_modules ./node_modules
COPY . .
EXPOSE 3000
# Lightweight healthcheck hitting the Elysia /api/health route.
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://127.0.0.1:3000/api/health || exit 1
CMD ["bun", "run", "src/index.ts"]

17
backend/package.json Normal file
View file

@ -0,0 +1,17 @@
{
"name": "test-app-backend",
"version": "0.1.0",
"description": "ElysiaJS (Bun) backend for test-app-stack",
"type": "module",
"scripts": {
"dev": "bun run --watch src/index.ts",
"start": "bun run src/index.ts"
},
"dependencies": {
"elysia": "^1.1.27",
"@elysiajs/cors": "^1.1.1"
},
"devDependencies": {
"bun-types": "^1.1.34"
}
}

35
backend/src/index.ts Normal file
View file

@ -0,0 +1,35 @@
import { Elysia, t } from "elysia";
import { cors } from "@elysiajs/cors";
const PORT = Number(process.env.PORT ?? 3000);
// CORS: allow the frontend origin. In production set FRONTEND_ORIGIN to the
// public frontend URL; defaults to "*" for local development convenience.
const FRONTEND_ORIGIN = process.env.FRONTEND_ORIGIN ?? "*";
const app = new Elysia()
.use(cors({ origin: FRONTEND_ORIGIN }))
.get("/", () => ({
service: "test-app-stack backend",
runtime: "ElysiaJS on Bun",
status: "ok",
}))
// Health probe used by Docker / Traefik / monitoring.
.get("/api/health", () => ({
status: "healthy",
timestamp: new Date().toISOString(),
}))
// Demo endpoint the frontend calls to prove the front<->back connection.
.get("/api/hello", ({ query }) => ({
message: `Hello${query.name ? `, ${query.name}` : ""} from ElysiaJS + Bun!`,
timestamp: new Date().toISOString(),
}), {
query: t.Object({ name: t.Optional(t.String()) }),
})
.listen(PORT);
console.log(
`🦊 Backend running at http://${app.server?.hostname}:${app.server?.port}`,
);
export type App = typeof app;

13
backend/tsconfig.json Normal file
View file

@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"types": ["bun-types"],
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowImportingTsExtensions": true,
"noEmit": true
}
}