Code Monkey home page Code Monkey logo

bookaholic-api-expressjs's Introduction

Bookaholic API

This Node.js application provides an API for managing books and categories, offering full CRUD functionality.

Features

  • Easily manage books and categories with intuitive CRUD operations.
  • Effortlessly filter books by various parameters such as title, publication year, and number of pages.

Setup

  1. Clone Repository:

    git clone https://github.com/diazlp/bookaholic-api-expressjs
    cd bookaholic-api-expressjs
  2. Install Dependencies:

    npm install
  3. Database Configuration:

    Navigate to config/config.js and configure your database settings:

    "username": "postgres",
    "password": "postgres",
    "database": "bookaholic-dev",
    "host": "127.0.0.1",
    "dialect": "postgres"
  4. Run Migration & Seeder:

    Execute the following commands to run migrations and seeders:

    npx sequelize-cli db:migrate && npx sequelize-cli db:seed:all

    Default credentials:

    username: admin
    password: admin
  5. Run the Server:

    npm run dev
  6. Accessing the server:

    Explore the API documentation at http://localhost:8000/docs.

    Access the API at http://localhost:8000.

API Endpoints

Authentication

  • POST /auth/register: Register a new user.
  • POST /auth/login: Log in with existing credentials.

Categories

  • GET /categories: Retrieve all categories.
  • POST /categories: Create a new category.
  • PATCH /categories/:id: Update an existing category by ID.
  • DELETE /categories/:id: Delete a category by ID.
  • GET /categories/:id/books: Retrieve all books within a specific category.

Books

  • GET /books: Retrieve all books.
  • POST /books: Create a new book.
  • PATCH /books/:id: Update an existing book by ID.
  • DELETE /books/:id: Delete a book by ID.

Filtering Books

  • Use query parameters to filter books and/or categories:
    • title: Search by book title (case-insensitive).
    • minYear: Minimum publication year.
    • maxYear: Maximum publication year.
    • minPage: Minimum number of pages.
    • maxPage: Maximum number of pages.
    • sortByTitle: Sort books by title in ascending (asc) or descending (desc) order.

Example:

  • localhost:8000/books?sortByTitle=asc&minYear=2000&maxPage=150
  • localhost:8000/books?title=algoritma&minYear=2000&maxYear=2010
  • localhost:8000/categories/1/books?sortByTitle=desc&minYear=2000&maxPage=150

Technologies Used

  • Express.js
  • Bcrypt for Password Hashing
  • JWT for Authentication
  • Sequelize ORM for PostgreSQL Database
  • Swagger for API Documentation

Contributors

bookaholic-api-expressjs's People

Contributors

diazlp avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.