GitHunt
DE

Deshan555/diaryAPI

๐Ÿš€ This API allows you to manage your daybook entries, recording your thoughts, moods, and experiences. Keep track of your journey with ease! ๐ŸŒŸ

diaryAPI Documentation ๐Ÿ“”

Welcome to the Daybook API documentation! ๐Ÿš€ This API allows you to manage your daybook entries, recording your
thoughts, moods, and experiences. Keep track of your journey with ease! ๐ŸŒŸ

alt text

Introduction ๐Ÿ“

The Daybook API empowers you to capture your daily experiences, emotions, and reflections. Each entry contains essential
details like title, content, timestamp, location, mood, and a unique entry code.

Getting Started ๐Ÿš€

Prerequisites ๐Ÿ› ๏ธ

  • Postman or any other API testing tool for testing the endpoints.

Installation ๐Ÿ’ป

  1. Clone the DiaryAPI repository from GitHub: git clone https://github.com/Deshan555/diaryAPI/tree/master
  2. Navigate to the project directory: cd diary-api
  3. Build the Docker container for the PostgreSQL database: docker-compose up -d
  4. Create New Database Name diary
# pasql -U admin
/bin/sh: 1: pasql: not found
# psql -U admin
psql (15.4 (Debian 15.4-1.pgdg120+1))
Type "help" for help.

admin=# CREATE DATABASE diary;
CREATE DATABASE
admin=# 
  1. Run the Spring Boot application: ./mvnw spring-boot:run

The API is now up and running! ๐ŸŽ‰

API Endpoints ๐Ÿ›ค๏ธ

Add Entry ๐Ÿ“

Add a new daybook entry.

  • Endpoint: POST /api/v1/daybook/add

  • Request Body:

    {
    "title": "A Peaceful Morning",
    "content": "Started the day with a calm meditation session. It helped set a positive tone for the entire day.",
    "location": "Home",
    "mood": "Relaxed"
    }
  • Response: Newly created entry details.

    {
    "id": 8,
    "title": "A Peaceful Morning",
    "content": "Started the day with a calm meditation session. It helped set a positive tone for the entire day.",
    "timestamp": "1692686335597",
    "location": "Home",
    "mood": "Relaxed",
    "entryCode": "ad5690bd-c7ff-4421-84f5-48d8ba1c75df"
    }

Update Entry โœ๏ธ

Update an existing daybook entry.

  • Endpoint: PUT /api/v1/daybook/update
  • Request Body:
    {
        "id": 1,
        "title": "Updated Entry",
        "content": "This is an updated entry...",
        "timestamp": "2023-08-21T15:30:00Z",
        "location": "City",
        "mood": "Happy",
        "entryCode": "ABCDE12345"
    }
  • Response: Updated entry details.

Find Entry by ID ๐Ÿ”

Retrieve a specific daybook entry by its ID.

  • Endpoint: GET /api/v1/daybook/find/{id}
  • Response: Found entry details.

Get All Entries ๐Ÿ“‹

Retrieve a list of all daybook entries.

  • Endpoint: GET /api/v1/daybook/all
  • Response: List of all entries.
[
  {
    "id": 2,
    "title": "A Peaceful Morning",
    "content": "Started the day with a calm meditation session. It helped set a positive tone for the entire day.",
    "timestamp": "1692686333844",
    "location": "Home",
    "mood": "Relaxed",
    "entryCode": "9d009c63-ad7e-4a1d-9304-ea7b061f0b68"
  },
  {
    "id": 3,
    "title": "A Peaceful Morning",
    "content": "Started the day with a calm meditation session. It helped set a positive tone for the entire day.",
    "timestamp": "1692686334402",
    "location": "Home",
    "mood": "Relaxed",
    "entryCode": "133de12e-be4f-42c4-8b44-194fca10ac4e"
  }
]

Delete Entry ๐Ÿ—‘๏ธ

Delete a daybook entry by its ID.

  • Endpoint: DELETE /api/v1/daybook/drop/{id}
  • Response: No content.
{
  "message": "Content deleted id : 1"
}

Swagger Documentation ๐Ÿ“–

Explore and test the API using the interactive Swagger documentation. Access it by navigating to Swagger UI once the API is running.http://localhost:8083/swagger-ui/index.html#/controller/getContentByID

Error Codes โŒ

The API may return the following error codes:

  • 400 Bad Request: Invalid request format or parameters.
  • 404 Not Found: Resource not found.
  • 500 Internal Server Error: Server-side errors.

Contributing ๐Ÿ‘ฅ

We welcome contributions to enhance the Daybook API! Feel free to submit pull requests or open issues.

License ๐Ÿ“œ

This project is licensed under the MIT License.


Thank you for using the Daybook API! ๐Ÿ“” If you have any questions or suggestions, please don't hesitate to reach out. Happy journaling! ๐ŸŒˆ