A Library Management System built with Node.js, Express, Sequelize, PostgreSQL, JWT for user authentication, and Docker for easy deployment.
- User registration and authentication
- Admin and user roles with different access levels
- Book management (CRUD operations)
- Borrow and return books with user-specific transactions
- Access control for different user roles
- Node.js
- PostgreSQL
- Clone the repository:
git clone [email protected]:csuonereal/library-management-system.git
- Install dependencies:
npm install
- Set environment variables in
.env
:DB_HOST=localhost DB_USER=postgres DB_PASSWORD=yourpassword DB_NAME=librarydb JWT_SECRET=yourjwtsecret PORT=8080 ADMIN_EMAIL[email protected] ADMIN_USERNAME=admin ADMIN_PASSWORD=admin123
- Run the server:
npm start
-
Ensure Docker and Docker Compose are installed on your system.
-
Build and run the containers:
docker-compose up --build
/api/auth/signup
: Register a new user./api/auth/signin
: Authenticate a user and get a token./api/books
: Perform CRUD operations on books./api/userbooks/borrow
: Borrow a book./api/userbooks/return
: Return a borrowed book./api/test/all
: Public access route./api/test/user
: User access route./api/test/admin
: Admin access route./api/users/:pk
: Get a user by primary key (admin only)./api/users
: Get all users (admin only).
To lint and format your code using ESLint and Prettier, you can use the following commands:
- To check for linting issues:
npm run lint
- To automatically fix linting issues:
npm run lint:fix
- To format your code using Prettier:
npm run format