REST API built with Node.js and Express for book management. Includes JWT authentication and complete CRUD operations.
- Node.js
- Express 5.1.0
- Sequelize 6.37.7
- PostgreSQL 8.16.3
- JWT (jsonwebtoken 9.0.2)
- Passport.js 0.7.0
- Node.js (recommended version: 18.x or higher)
- PostgreSQL
- npm
- Clone the repository:
git clone [REPOSITORY_URL] cd [PROJECT_NAME]- Install dependencies:
npm install- 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
- Run migrations:
npx sequelize-cli db:migrate- JWT Authentication system
- Complete CRUD for books
- Pagination and sorting
- Data validation
- Data transformers
- Exception handling
POST /auth/register- Register new userPOST /auth/login- Login user
GET /user/me- Get current user
POST /books- Create new bookGET /books- Get list of books (with pagination)PUT /books/:uuid- Update bookDELETE /books/:uuid- Delete book
- : Page number (default: 1)
page - : Items per page (default: 5)
limit - : Sort field and order (example: "title:DESC")
sortBy
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 codeThis project uses:
- ESLint (v9.30.0) for linting
- Prettier (v3.6.2) for code formatting
ISC
- Fork the repository
- Create a new branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -am 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Create a Pull Request