A modern Node.js backend for the Petfinder v2 API, built with TypeScript, demonstrating async/await, modular routes, and API integration. Includes environment configuration, error handling, and automated tests.
- TypeScript + Node.js 22
- Express REST API with modular routes
- Environment variable configuration using
.env - Petfinder v2 API integration with OAuth2
- Async/await and error handling
- Logging with morgan
- CORS enabled for cross-origin requests
- Automated testing with Jest & Supertest
- Getting Started
- Environment Variables
- Available Endpoints
- Running Tests
- Technologies
- License
- Clone the repository
git clone https://github.com/Travisaurus-Rex/petfinder/
cd petfinder- Install dependencies
npm install- Set up
.envfile
PETFINDER_KEY=your_api_key_here
PETFINDER_SECRET=your_api_secret_here
PORT=8080
- Start the server
npm startServer runs at http://localhost:8080
| Variable | Description |
|---|---|
| PETFINDER_KEY | Your Petfinder API key |
| PETFINDER_SECRET | Your Petfinder API secret |
| PORT | Port for the Express server (default: 8080) |
| Endpoint | Method | Description |
|---|---|---|
| /pet/random | GET | Returns a single random pet |
| /pet/:id | GET | Returns a single pet by ID |
| /pet/find/:location? | GET | Returns pets by location (default: 47665) |
Example:
curl http://localhost:8080/pet/random| Endpoint | Method | Description |
|---|---|---|
| /shelter/:location | GET | Returns details about a shelter by location |
| /shelter/:location/pets | GET | Returns all pets in a specific shelter |
Example:
curl http://localhost:8080/shelter/47665/petsnpm test- Tests use Jest + Supertest
- Make sure
.envis configured before running tests - Checks endpoints return expected data structure
- Node.js 22
- TypeScript
- Express
- dotenv
- CORS
- Morgan
- node-fetch
- Jest + Supertest
MIT License