Files
elysiajs-boilerplate/README.md
T

36 lines
1.6 KiB
Markdown

# ElysiaJS Boilerplate
Starter for the ElysiaJS coursework workspace: Bun + ElysiaJS + TypeScript,
with MySQL (Drizzle ORM) and Redis wired up to the shared course databases.
## Development
```bash
bun install
bun run db:push # creates the `notes` table from src/db/schema.ts
bun run dev
```
Open http://localhost:3000/swagger for interactive API docs (auto-generated
from the routes in `src/index.ts`).
## What's here
- `src/index.ts` - the app: a couple of example routes showing MySQL reads/
writes via `src/db` and Redis reads/writes via `src/redis.ts`. Delete the
examples once you understand the pattern and start building your own.
- `src/db/schema.ts` - your Drizzle table definitions. Add tables here, then
run `bun run db:push` to sync them to MySQL (no migration files needed for
coursework - `push` just diffs your schema against the live database).
- `src/db/index.ts` / `src/redis.ts` - pre-configured clients, reading
connection details from environment variables. In your Coder workspace
these are already set for you (`MYSQL_*`, `REDIS_*`) - you never need to
type a password into code.
- `.env.example` - only needed if you want to run this outside your Coder
workspace, against your own local MySQL/Redis.
## Notes
- Your Redis user can only touch keys under `student:<your-username>:*`
(enforced by the server) - that's why `src/index.ts` prefixes cache keys
with `REDIS_USERNAME`. Keys outside that prefix will be rejected.
- Your MySQL user only has access to your own database - no need to specify
it beyond what's already in `MYSQL_DATABASE`.