PhotosAPI is a simple and efficient API for managing and serving photos. Built with Express and Node.js, PhotosAPI allows you to easily upload, retrieve, and manage photo collections.
- Retrieve all photos
- Retrieve a single photo by ID
- Add a new photo
- Update a photo by ID
- Partially update a photo by ID
- Delete a photo by ID
- Search photos by description
- Node.js (version >= 20.13.1)
- npm
-
Clone the repository:
git clone https://github.com/yourusername/photosapi.git cd photosapi
-
Install the dependencies:
npm install
-
Create a
photos.json
file in the root directory with the following content:[ { "description": "Beautiful landscape with mountains", "url": "https://images.unsplash.com/photo-1506748686214-e9df14d4d9d0" }, { "description": "Aerial view of a city", "url": "https://images.unsplash.com/photo-1517524285303-d6fc683dddf8" }, ... ]
-
Start the server:
npm start
For development mode with auto-reloading:
npm run dev
-
The server will be running on
http://localhost:3000
.
- URL:
/photos
- Method:
GET
- Response: Array of photo objects
- URL:
/photos/:id
- Method:
GET
- URL Params:
id
: Photo ID
- Response: Photo object
- URL:
/photos
- Method:
POST
- Body Params:
description
: Description of the photourl
: URL of the photo
- Response: Newly created photo object
- URL:
/photos/:id
- Method:
PUT
- URL Params:
id
: Photo ID
- Body Params:
description
: Description of the photourl
: URL of the photo
- Response: Updated photo object
- URL:
/photos/:id
- Method:
PATCH
- URL Params:
id
: Photo ID
- Body Params:
description
(optional): New description of the photourl
(optional): New URL of the photo
- Response: Updated photo object
- URL:
/photos/:id
- Method:
DELETE
- URL Params:
id
: Photo ID
- Response: 204 No Content
- URL:
/photos/search
- Method:
GET
- Query Params:
description
: Keyword to search in the description
- Response: Array of matching photo objects
Contributions are welcome! Please open an issue or submit a pull request for any changes.
This project is licensed under the MIT License - see the LICENSE file for details.