Skip to content

A REST API for managing a book collection. Built with Node.js, Express, and MongoDB.

License

Notifications You must be signed in to change notification settings

Nec0ti/LibrisAPI

Repository files navigation

LibrisAPI

LibrisAPI is a RESTful API for managing your personal book collection.

Purpose

This API allows you to:

  • Create, retrieve, update, and delete books.
  • Authenticate users with JWT (JSON Web Tokens).

Documentation

For detailed information on how to use the API, please refer to the LibrisAPI Documentation.

Getting Started

  1. Clone the repository:

    git clone https://github.com/Nec0ti/LibrisAPI/
    cd LibrisAPI
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    Create a .env file with the following variables:

    MONGODB_URI=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/<database>?retryWrites=true&w=majority
    JWT_SECRET=your_jwt_secret_key
    
  4. Start the server:

    npm run dev

Endpoints

Here are a few basic examples:

  • Register: POST /api/auth/register

    {
      "username": "testuser",
      "password": "testpassword"
    }
  • Login: POST /api/auth/login

    {
      "username": "testuser",
      "password": "testpassword"
    }
  • Get All Books: GET /api/books (requires JWT token in x-auth-token header)

Contributing

We welcome contributions! Please feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License.