Mercurial
comparison react_games/backend/server.ts @ 37:fb9bcd3145cb
[ReactGames] Few games I made using react just to practice few things.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 01 Dec 2025 20:22:47 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 36:84672efec192 | 37:fb9bcd3145cb |
|---|---|
| 1 import express from 'express'; | |
| 2 import path from 'node:path'; | |
| 3 import { createTodoRouter } from './routes/todo'; | |
| 4 import { createWebRouter } from './routes/web'; | |
| 5 import { createWorldeRouter } from './routes/wordle'; | |
| 6 | |
| 7 const app = express(); | |
| 8 app.use(express.json()); | |
| 9 | |
| 10 const ROOT = process.cwd(); | |
| 11 const PUBLIC_DIR = path.resolve(ROOT, 'public'); | |
| 12 const DATA_FILE = path.resolve(ROOT, 'data', 'todos.json'); | |
| 13 const PORT = Number(process.env.PORT) || 4000; | |
| 14 | |
| 15 const SPA_MOUNTS = [ | |
| 16 { baseUrl: '/games', entryHtml: 'games/index.html' }, | |
| 17 ]; | |
| 18 | |
| 19 app.use('/api/v1/todo', createTodoRouter(DATA_FILE)); | |
| 20 app.use('/api/v1/wordle', createWorldeRouter()); | |
| 21 app.use('/', createWebRouter(PUBLIC_DIR, SPA_MOUNTS)); | |
| 22 | |
| 23 app.listen(PORT, () => { | |
| 24 console.log(`→ http://localhost:${PORT}`); | |
| 25 }); | |
| 26 |