This directory contains a comprehensive Postman collection and environment for testing all the Buddies Inn API endpoints.
BuddiesInn_API_Collection.postman_collection.json- Complete API collectionBuddiesInn_Environment.postman_environment.json- Environment variables
- Open Postman
- Click "Import" button
- Upload both JSON files:
BuddiesInn_API_Collection.postman_collection.jsonBuddiesInn_Environment.postman_environment.json
- In Postman, select "Buddies Inn Environment" from the environment dropdown
- Update the
BASE_URLif your server runs on a different port
npm run dev- GET
/- Root endpoint - GET
/api/health- Health check with system info - GET
/api/test- Test route
- POST
/api/auth/register- Register new user - POST
/api/auth/login- Login user - GET
/api/auth/me- Get current user profile
- GET
/api/categories- Get all categories - GET
/api/categories/:id- Get category by ID - POST
/api/categories- Create category (Auth required) - PUT
/api/categories/:id- Update category (Auth required) - DELETE
/api/categories/:id- Delete category (Auth required)
- GET
/api/products- Get all products with filtering - GET
/api/products/:id- Get product by ID - POST
/api/products- Create product (Auth required) - PUT
/api/products/:id- Update product (Auth required) - DELETE
/api/products/:id- Delete product (Auth required)
- GET
/api/cart- Get user's cart (Auth required) - POST
/api/cart/items- Add item to cart (Auth required) - PUT
/api/cart/items/:itemId- Update cart item (Auth required) - DELETE
/api/cart/items/:itemId- Remove cart item (Auth required) - DELETE
/api/cart- Clear entire cart (Auth required)
- POST
/api/orders- Create order from cart (Auth required) - GET
/api/orders- Get user's orders (Auth required) - GET
/api/orders/:id- Get order by ID (Auth required)
- GET
/api/products/:productId/reviews- Get product reviews - POST
/api/products/:productId/reviews- Create review (Auth required) - DELETE
/api/reviews/:id- Delete review (Auth required)
- Register a new user using the "Register User" request
- The auth token will be automatically saved to environment variables
- Or Login with existing credentials
- The token is automatically used for subsequent authenticated requests
- Create categories first (required for products)
- Create products using the category IDs
- Save the returned IDs in environment variables for further testing
- Add items to cart using product IDs
- Update cart items to test quantity changes
- Create an order from the cart
- View orders to verify creation
- Create reviews for products you've ordered
- View product reviews to see them listed
- Delete reviews if needed
{
"number": "+1234567890",
"password": "password123",
"userName": "testuser",
"phone": "+1234567890"
}{
"name": "Electronics",
"description": "Electronic devices and accessories",
"image": "https://example.com/electronics.jpg",
"sortOrder": 1,
"isActive": true
}{
"name": "iPhone 15",
"description": "Latest iPhone with advanced features",
"price": 999.99,
"categoryId": "your_category_id_here",
"stock": 100,
"featured": true,
"status": "ACTIVE",
"images": [
{
"url": "https://example.com/iphone15.jpg",
"altText": "iPhone 15",
"sortOrder": 0
}
]
}The following variables are automatically managed:
BASE_URL- API base URL (default: http://localhost:3000)AUTH_TOKEN- Automatically set after login/registerUSER_ID- User ID for referencePRODUCT_ID- Product ID for testingCATEGORY_ID- Category ID for testingCART_ITEM_ID- Cart item ID for testingORDER_ID- Order ID for testingREVIEW_ID- Review ID for testing
The collection includes error test cases:
- 404 errors - Non-existent routes
- 400 errors - Invalid JSON, validation errors
- 401 errors - Unauthorized access
- 500 errors - Server errors
- User authentication now uses
numberfield instead ofemail - Make sure your database schema matches the updated Prisma schema
- All authenticated endpoints require a Bearer token
- Tokens are automatically managed by the collection
- Tokens expire after 7 days (configurable in backend)
- Ensure your PostgreSQL database is running
- Run migrations:
npx prisma migrate dev - Generate client:
npx prisma generate
- Connection refused - Make sure your server is running on the correct port
- Authentication errors - Check if the token is valid and not expired
- Database errors - Ensure PostgreSQL is running and migrations are applied
- Validation errors - Check request body format matches the expected schema
Run your server in development mode to see detailed logs:
npm run devUse Prisma Studio to inspect your database:
npx prisma studioIf you encounter any issues:
- Check the server logs for detailed error messages
- Verify database connection and schema
- Ensure all required environment variables are set
- Check that all required fields are included in request bodies