Skip to content

alu0101540153/LibroShelf_Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

đź“– LibroShelf Backend API

API REST for the LibroShelf web

Node.js TypeScript Express MongoDB

📚 Project Overview

LibroShelf Backend API is a RESTful service designed to power the LibroShelf web application. It provides endpoints for managing books, users, authentication, and other core features. Built with Node.js, TypeScript, Express, and MongoDB, the API ensures scalability, security, and maintainability.

For the books database , i used GoogleBooksAPI.

🗂️ Architecture Diagram

LibroShelf Backend Architecture

🚀 Features

  • User authentication and authorization (JWT)
  • CRUD operations for books and users
  • Search and filter books
  • Secure password hashing
  • Error handling and validation
  • Environment-based configuration
  • Books info , with the thumbnail

Funtions:

  • Follow sistem
  • Save your books
  • rate your own books and add comments

🛠️ Installation

  1. Clone the repository:
git clone https://github.com/your-username/LibroShelf_Backend.git
cd LibroShelf_Backend
  1. Install dependencies:
npm install
  1. Configure environment variables:
  • Copy .env.example to .env and update the values.
  1. Run the development server:
npm run dev

đź“‘ API Documentation

User Endpoints

Base URL: http://localhost:4000/api/users


1. Get Authenticated User

  • Endpoint: /user
  • Method: GET
  • Auth: Bearer Token required
  • Description: Returns the authenticated user’s profile data.

2. Authenticate User (Login)

  • Endpoint: /auth/login
  • Method: POST
  • Auth: None
  • Description: Authenticates a user and returns a token.
  • Body (JSON):
    {
      "email": "victor@gmail.com",
      "password": "12345678"
    }

3. Register New User

  • Endpoint: /auth/register
  • Method: POST
  • Auth: None
  • Description: Creates a new user account.
  • Body (JSON):
    {
      "handle": "Paula",
      "name": "paula",
      "email": "paula@gmail.com",
      "password": "12345678"
    }

4. Follow a User

  • Endpoint: /follow
  • Method: POST
  • Auth: Bearer Token required
  • Description: Follows another user by their handle.
  • Body (JSON):
    {
      "handle": "victor"
    }

5. Unfollow a User

  • Endpoint: /unfollow
  • Method: POST
  • Auth: Bearer Token required
  • Description: Unfollows a user by their handle.
  • Body (JSON):
    {
      "handle": "paula"
    }

6. Get User Feed

  • Endpoint: /feed
  • Method: GET
  • Auth: Bearer Token required
  • Description: Returns the feed of posts from followed users.

📚 Books Endpoints

1. Add a Book

  • Endpoint: /add
  • Method: POST
  • Auth: Bearer Token required
  • Description: Adds a book to the authenticated user’s collection.
  • Body (JSON):
    {
      "bookId": "8FjODwAAQBAJ"
    }

2. Search Book by Title

  • Endpoint: /search
  • Method: GET
  • Auth: None
  • Description: Searches for books by title.
  • Body (JSON):
    {
      "title": "harry potter"
    }

3. Delete a Book

  • Endpoint: /delete
  • Method: DELETE
  • Auth: Bearer Token required
  • Description: Deletes a book from the authenticated user’s collection.
  • Body (JSON):
    {
      "bookId": "89tu0AEACAAJ"
    }

4. List All Books of a User

  • Endpoint: /list
  • Method: POST
  • Auth: None
  • Description: Lists all books belonging to a specific user by handle.
  • Body (JSON):
    {
      "handle": "paula"
    }

5. Get All My Books

  • Endpoint: /mybooks
  • Method: GET
  • Auth: Bearer Token required
  • Description: Returns all books in the authenticated user’s collection.

6. Add or Update Rating

  • Endpoint: /update
  • Method: PUT
  • Auth: Bearer Token required
  • Description: Adds or updates a rating and review for a book.
  • Body (JSON):
    {
      "id": "8FjODwAAQBAS",
      "rating": 3,
      "description": "me gusto muchoo"
    }

🤝 Contributing

Contributions are welcome! Please open issues or submit pull requests for improvements.

About

📚LibroShelf Backend API is a RESTful service designed to power the LibroShelf web application. It provides endpoints for managing books, users, authentication, and other core features. Built with Node.js, TypeScript, Express, and MongoDB, the API ensures scalability, security, and maintainability.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors