Skip to content

REST API built with Node.js and Express for book management. Includes JWT authentication and complete CRUD operations.

Notifications You must be signed in to change notification settings

rafaelmm899/personal-library-api

Repository files navigation

Book Management API

Description

REST API built with Node.js and Express for book management. Includes JWT authentication and complete CRUD operations.

Core Technologies

  • Node.js
  • Express 5.1.0
  • Sequelize 6.37.7
  • PostgreSQL 8.16.3
  • JWT (jsonwebtoken 9.0.2)
  • Passport.js 0.7.0

Prerequisites

  • Node.js (recommended version: 18.x or higher)
  • PostgreSQL
  • npm

Installation

  1. Clone the repository:
git clone [REPOSITORY_URL] cd [PROJECT_NAME]
  1. Install dependencies:
npm install
  1. Configure environment variables
Create a file in the project root: `.env`
DB_HOST=localhost
DB_PORT=5432
DB_NAME=database_name
DB_USER=user
DB_PASSWORD=password
JWT_SECRET=your_jwt_secret
  1. Run migrations:
npx sequelize-cli db:migrate

Features

  • JWT Authentication system
  • Complete CRUD for books
  • Pagination and sorting
  • Data validation
  • Data transformers
  • Exception handling

Endpoints

Auth

  • POST /auth/register - Register new user
  • POST /auth/login - Login user

Users

  • GET /user/me - Get current user

Books

  • POST /books - Create new book
  • GET /books - Get list of books (with pagination)
  • PUT /books/:uuid - Update book
  • DELETE /books/:uuid - Delete book

Query Parameters

  • : Page number (default: 1) page
  • : Items per page (default: 5) limit
  • : Sort field and order (example: "title:DESC") sortBy

Available Scripts

npm start          # Start the server
npm run dev        # Start the server in development mode
npm test          # Run tests
npm run lint      # Run ESLint
npm run prettier  # Format code

Code Standards

This project uses:

  • ESLint (v9.30.0) for linting
  • Prettier (v3.6.2) for code formatting

License

ISC

Contributing

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -am 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Create a Pull Request

About

REST API built with Node.js and Express for book management. Includes JWT authentication and complete CRUD operations.

Resources

Stars

Watchers

Forks

Packages

No packages published