Cat Data API
The Cat Data API is a secure REST API for managing and storing cat images. It provides endpoints for uploading, retrieving, listing, and deleting images with JWT-based authentication powered by Auth0.What You Can Do
The Cat Data API enables you to:- Upload Images: Store JPG and PNG cat images securely
- Retrieve Images: Fetch individual images by ID
- List All Images: Get metadata for all stored images
- Delete Images: Remove images from storage and database
- Secure Access: All endpoints are protected with Auth0 JWT authentication
Architecture Overview
The Cat Data API is built with a modern, secure stack:Express.js
Fast, minimalist web framework for the API server
PostgreSQL
Reliable relational database for image metadata storage
Auth0
Enterprise-grade JWT authentication and authorization
Tech Stack
- Runtime: Node.js with TypeScript
- Web Framework: Express.js
- Database: PostgreSQL with Knex.js query builder
- Authentication: Auth0 with JWT tokens (RS256 algorithm)
- File Upload: Multer middleware for multipart/form-data
- File Storage: Local filesystem with UUID-based naming
API Endpoints
All endpoints require authentication except the root endpoint:| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | / | Health check | No |
| POST | /api/upload | Upload a new image | Yes |
| GET | /api/images | List all images | Yes |
| GET | /api/image/:id | Get a specific image | Yes |
| DELETE | /api/image/:id | Delete an image | Yes |
All authenticated endpoints validate JWT tokens using Auth0’s JWKS (JSON Web Key Set) endpoint.
Key Features
Secure by Default
Every API endpoint (except the health check) requires a valid JWT token from Auth0. The API validates tokens using RS256 asymmetric encryption and verifies them against Auth0’s public keys.File Type Validation
Only JPG and PNG image files are accepted. The API validates file types using MIME type checking:Automatic File Management
Images are stored with UUID-prefixed filenames to prevent collisions and ensure uniqueness across uploads.Getting Started
Quickstart
Get up and running in 5 minutes
Authentication
Learn how to authenticate your requests
CORS Configuration
The API is configured to accept requests fromhttp://localhost:5173 with credentials support:
For production deployments, update the CORS origin to match your frontend domain.