GithubHelp home page GithubHelp logo

pintu544 / bookstore Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10 KB

This is a CRUD (Create, Read, Update, Delete) API with user authentication using JSON Web Tokens (JWT). It allows users to register, login, and perform CRUD operations on books.

Home Page: https://bookstore-ten-zeta.vercel.app

JavaScript 100.00%
expressjs mongodb mongoose nodejs

bookstore's Introduction

Live deploy link :- https://bookstore-ojh2zrcab-pintu870s-projects.vercel.app/api/books

# CRUD API with Authentication

This is a CRUD (Create, Read, Update, Delete) API with user authentication using JSON Web Tokens (JWT). It allows users to register, login, and perform CRUD operations on books.

## Features

- User registration
- User login with JWT authentication
- Get current user profile
- Create, read, update, and delete books

## Technologies Used

- Node.js
- Express.js
- MongoDB
- Mongoose
- JSON Web Tokens (JWT)
- bcrypt.js
- dotenv

## Getting Started

### Prerequisites

Make sure you have Node.js and MongoDB installed on your machine.

### Installation

1. Clone the repository:

   ```bash
   git clone https://github.com/pintu544/Bookstore
  1. Install dependencies:

    cd Bookstore
    npm install
  2. Set environment variables:

    Create a .env file in the root directory of your project. Add the following environment variables:

    MONGO_URI=mongodb://localhost:27017/your_database
    PORT=3000
    JWT_SECRET=your_secret_key
    
  3. Run the application:

    npm start

API Endpoints

Authentication

Register User

  • URL: /api/auth/register

  • Method: POST

  • Request Body:

    {
        "username": "your_username",
        "password": "your_password"
    }
  • Response:

    {
        "_id": "user_id",
        "username": "your_username",
        "token": "your_jwt_token"
    }

Login User

  • URL: /api/auth/login

  • Method: POST

  • Request Body:

    {
        "username": "your_username",
        "password": "your_password"
    }
  • Response:

    {
        "_id": "user_id",
        "username": "your_username",
        "token": "your_jwt_token"
    }

Books

Get All Books

  • URL: /api/books
  • Method: GET
  • Authentication: Required

Get Single Book

  • URL: /api/books/:id
  • Method: GET
  • Authentication: Required

Create Book

  • URL: /api/books

  • Method: POST

  • Authentication: Required

  • Request Body:

    {
        "title": "book_title",
        "author": "book_author",
        "publicationYear": 2022,
        "isbn": "book_isbn"
    }

Update Book

  • URL: /api/books/:id

  • Method: PUT

  • Authentication: Required

  • Request Body:

    {
        "title": "updated_book_title",
        "author": "updated_book_author",
        "publicationYear": 2023,
        "isbn": "updated_book_isbn"
    }

Delete Book

  • URL: /api/books/:id
  • Method: DELETE
  • Authentication: Required

bookstore's People

Contributors

pintu544 avatar

Watchers

 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.