From 3dfadafb251e7ccc7e05c4de2fa444a4341030e8 Mon Sep 17 00:00:00 2001 From: Marcelle Date: Sat, 7 Mar 2026 20:56:40 -0300 Subject: [PATCH 1/2] Add README.md --- README.md | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f33db60 --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ +# Upload Server + +A REST API for image uploads built with Fastify, TypeScript, PostgreSQL, and Cloudflare R2. + +## Features + +- Image upload to Cloudflare R2 (S3-compatible storage) +- Paginated upload listing with sorting +- CSV export of upload records +- OpenAPI docs via Swagger UI at `/docs` + +## Tech Stack + +- **Runtime:** Node.js with TypeScript +- **Framework:** Fastify +- **Database:** PostgreSQL + Drizzle ORM +- **Storage:** Cloudflare R2 (AWS S3 SDK) +- **Validation:** Zod +- **Testing:** Vitest + +## Getting Started + +### Prerequisites + +- Node.js 22+ +- pnpm +- PostgreSQL instance +- Cloudflare R2 bucket + +### Setup + +1. Install dependencies: + ```bash + pnpm install + ``` + +2. Create a `.env` file with the required variables: + ```env + PORT=3333 + NODE_ENV=development + DATABASE_URL=postgresql://user:password@localhost:5432/dbname + + CLOUDFLARE_ACCOUNT_ID= + CLOUDFLARE_ACCESS_KEY_ID= + CLOUDFLARE_SECRET_ACCESS_KEY= + CLOUDFLARE_BUCKET= + CLOUDFLARE_PUBLIC_URL= + ``` + +3. Run database migrations: + ```bash + pnpm db:migrate + ``` + +4. Start the development server: + ```bash + pnpm dev + ``` + +## API Routes + +| Method | Path | Description | +|--------|------|-------------| +| `POST` | `/uploads` | Upload an image file | +| `GET` | `/uploads` | List uploads (paginated) | +| `GET` | `/uploads/export` | Export uploads as CSV | + +Full interactive docs available at `http://localhost:3333/docs`. + +## Testing + +```bash +# Run tests once +pnpm test + +# Watch mode +pnpm test:watch +``` + +Tests require a `.env.test` file with a separate test database URL. + +## Database + +```bash +pnpm db:generate # Generate migrations +pnpm db:migrate # Apply migrations +pnpm db:studio # Open Drizzle Studio +``` From d0ae26ecc4f7452ae8ad4049eeb2ccb040425f97 Mon Sep 17 00:00:00 2001 From: Marcelle Date: Sat, 7 Mar 2026 21:03:42 -0300 Subject: [PATCH 2/2] fix: remove hardcoded pnpm version from ci workflow --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 798d7b7..5e9f3ea 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,6 @@ jobs: - uses: pnpm/action-setup@v4 name: Install pnpm with: - version: 9 run_install: false - name: Install Node.js