60 lines
1.4 KiB
Markdown
60 lines
1.4 KiB
Markdown
# Backend Todo App Template
|
|
|
|
Backend-only Bun + Express template intended to be snapshotted directly and mounted at `/mnt/backend`.
|
|
|
|
## What it provides
|
|
|
|
- `GET /health`
|
|
- `GET /todos`
|
|
- `POST /todos`
|
|
- `GET /todos/:id`
|
|
- `PUT /todos/:id`
|
|
- `DELETE /todos/:id`
|
|
- `POST /todos/:id/attachment/presign`
|
|
- `POST /todos/:id/attachment/complete`
|
|
|
|
Todos are stored in Turso/libSQL through the HTTP pipeline API. Attachments use Tigris or any S3-compatible endpoint through presigned `PUT` URLs.
|
|
|
|
## Runtime contract
|
|
|
|
- app root is this folder
|
|
- start command: `bun run dev`
|
|
- listens on `PORT`, default `8080`
|
|
- compatible with a direct snapshot mounted to `/mnt/backend`
|
|
|
|
## Setup
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
bun install
|
|
bun run dev
|
|
```
|
|
|
|
## Required env
|
|
|
|
`.env` and `.env.example` contain the full key set expected by the app:
|
|
|
|
- `PORT`
|
|
- `NODE_ENV`
|
|
- `API_PREFIX`
|
|
- `CORS_ORIGIN`
|
|
- `LOG_LEVEL`
|
|
- `PROJECT_ID`
|
|
- `DATABASE_URL`
|
|
- `DATABASE_AUTH_TOKEN`
|
|
- `S3_ENDPOINT`
|
|
- `S3_BUCKET`
|
|
- `S3_PREFIX`
|
|
- `S3_ACCESS_KEY_ID`
|
|
- `S3_SECRET_ACCESS_KEY`
|
|
- `S3_SESSION_TOKEN`
|
|
|
|
## Attachment flow
|
|
|
|
1. Create a todo with `POST /todos`.
|
|
2. Request a presigned upload target with `POST /todos/:id/attachment/presign`.
|
|
3. Upload the file directly to the returned `url` using the returned `method` and `headers`.
|
|
4. Finalize the attachment metadata with `POST /todos/:id/attachment/complete`.
|
|
|
|
Deleting a todo only removes the database record in v1. It does not delete the object from storage.
|