A RESTful API for managing a pet store, built with Fastify and Node.js.
- 🔐 User Authentication with API Keys (only for 1 endpoint)
- 🐕 Pet Management
- 🛍️ Store Operations
- 📦 Order Processing
- Node.js
- Fastify
- JSON File Storage
GET /user/login- Login user and get API key- Query params:
username,password
- Query params:
GET /user/logout- Logout user- Query params:
username
- Query params:
GET /user/:username- Get user by usernamePUT /user/:username- Update userPOST /user- Create new userPOST /user/createWithList- Create multiple usersDELETE /user/:username- Delete user
GET /pet/:id- Get pet by IDGET /pet/findByStatus- Find pets by statusGET /pet/findByTags- Find pets by tagsPOST /pet/:id/uploadImage- Upload pet image (only .jpg)POST /pet/:id- Update pet with form dataPOST /pet- Add new petPUT /pet- Update petDELETE /pet/:id- Delete pet
GET /store/inventory- Get pet inventory by status- Requires API key
GET /store/order/:orderId- Find purchase order by IDPOST /store/order- Place an order for a petDELETE /store/order/:orderId- Delete purchase order by ID
One endpoint ( GET /store/inventory) require an API key for authentication that is granted on login. The API key should be included in the request header:
api_key: your_api_key_here
{
"id": 1,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}{
"id": 1,
"name": "string",
"photoUrls": ["string"],
"category": {
"id": 1,
"name": "string"
},
"tags": [
{
"id": 1,
"name": "string"
}
],
"status": "available"
}{
"id": 1,
"petId": 1,
"quantity": 1,
"shipDate": "2024-03-20T12:00:00Z",
"status": "placed",
"complete": false
}- Clone the repository
- Install dependencies:
npm install
- Start the server:
npm start dev