Skip to content

Modern Node.js backend for Petfinder v2 API built with TypeScript, demonstrating async/await, API integration, and modular route/service architecture. Includes environment configuration, error handling, and optional testing.

Notifications You must be signed in to change notification settings

Travisaurus-Rex/petfinder

Repository files navigation

Petfinder Backend

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.

Features

  • 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

Table of Contents

  • Getting Started
  • Environment Variables
  • Available Endpoints
  • Running Tests
  • Technologies
  • License

Getting Started

  1. Clone the repository
git clone https://github.com/Travisaurus-Rex/petfinder/
cd petfinder
  1. Install dependencies
npm install
  1. Set up .env file
PETFINDER_KEY=your_api_key_here
PETFINDER_SECRET=your_api_secret_here
PORT=8080
  1. Start the server
npm start

Server runs at http://localhost:8080


Environment Variables

Variable Description
PETFINDER_KEY Your Petfinder API key
PETFINDER_SECRET Your Petfinder API secret
PORT Port for the Express server (default: 8080)

Available Endpoints

Pets

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

Shelters

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/pets

Running Tests

npm test
  • Tests use Jest + Supertest
  • Make sure .env is configured before running tests
  • Checks endpoints return expected data structure

Technologies

  • Node.js 22
  • TypeScript
  • Express
  • dotenv
  • CORS
  • Morgan
  • node-fetch
  • Jest + Supertest

License

MIT License

About

Modern Node.js backend for Petfinder v2 API built with TypeScript, demonstrating async/await, API integration, and modular route/service architecture. Includes environment configuration, error handling, and optional testing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published