Skip to content

gblsmlo/ftr-upload-widget-server

Repository files navigation

Upload Widget Server

TypeScript Node.js Fastify Drizzle ORM PostgreSQL Vitest Biome

A backend service for image uploads, built with Fastify, Zod, Drizzle ORM, and Cloudflare R2 (via AWS SDK S3). It provides a REST API to upload images and stores metadata in PostgreSQL. Documentation is available at `/docs` using Swagger UI. Screenshot 2025-10-25 at 19 26 55

Tech Stack

Requirements

Environment Variables

Defined and validated in src/env.ts:

  • PORT (default: 3333)
  • NODE_ENV (development | test | production)
  • DATABASE_URL (e.g., postgresql://docker:docker@localhost:5432/upload)
  • CLOUDFLARE_BUCKET_NAME
  • CLOUDFLARE_ACCOUNT_ID
  • CLOUDFLARE_ACCESS_KEY
  • CLOUDFLARE_ACCESS_SECRET
  • CLOUDFLARE_PUBLIC_URL

Create a .env file with these variables for local development.

Getting Started

  1. Start PostgreSQL with Docker Compose:
    docker compose up -d
  2. Install dependencies:
    pnpm install
  3. Apply database migrations (Drizzle):
    pnpm db:migrate
  4. Run the development server:
    pnpm dev
  5. Open API docs (Swagger UI):

API Reference

  • POST /uploads: Upload an image (multipart/form-data).
  • GET /uploads: Get a list of all uploads.
  • POST /uploads/exports: Export uploads as a CSV file.

The OpenAPI schema is served and transformed for multipart via src/infra/http/server.ts and src/infra/http/transform-swagger-schema.ts.

Testing

Run the test suite:

pnpm test

Course Attribution

This project is part of a practical lesson in the postgraduate program "Tech Developer 360" at Rocketseat. Learn more at: https://www.rocketseat.com.br/faculdade/tech-developer-360

License

ISC (default). See the license field in package.json.

About

A backend service for image uploads, built with Fastify, Zod, Drizzle ORM, and Cloudflare R2 (via AWS SDK S3).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors