Installation guide
This guide provides comprehensive instructions for installing and configuring the Adoptme API in various environments.System requirements
Required software
- Node.js: Version 22 or higher
- MongoDB: Version 4.0 or higher
- npm: Comes bundled with Node.js
Verify Node.js version
Check your Node.js version:v22.0.0 or higher.
Installation methods
- Standard installation
- Development mode
- Docker installation
Environment configuration
Required environment variables
Create a.env file in the root directory of your project:
Environment variables reference
The port number where the Express server will listen for incoming requests
MongoDB connection string. For local development, use
mongodb://127.0.0.1:27017. For MongoDB Atlas or remote instances, use your full connection stringThe name of the MongoDB database to use for storing pets, users, and adoptions
Configuration file
The application uses thesrc/config/config.js file to load environment variables:
Start the server
Successful startup
When the server starts successfully, you’ll see:Verify installation
After starting the server, verify everything is working:Check server health
Ensure the server is running by checking the console output for the “Listening on” message.
Access Swagger documentation
Open your browser and navigate to:You should see the interactive Swagger API documentation.
Troubleshooting
Server won’t start
Error: Cannot connect to MongoDBPort already in use
Error:.env file to a different number (e.g., 3000, 5000) or stop the process using port 8080.
Node version incompatibility
Error:Missing environment variables
Error:.env file exists in the root directory and contains all required variables. The application requires a valid MongoDB connection.
Running tests
The project includes unit tests built with Mocha and Chai:test/ directory.
Tests use Supertest for HTTP assertions and Chai for test assertions. Ensure your test database is separate from your development database.
Next steps
Quickstart guide
Make your first API calls and generate mock data
API reference
Explore all available endpoints
Development guide
Learn about Docker deployment and building images
Authentication
Set up JWT authentication for your application