A simple library management system built with Node.js, Express, SQLite3, and Knex.js.
echo "# Librarian" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/aykutmayali/Librarian.git
git push -u origin main
git clone https://github.com/aykutmayali/Librarian.git
cd Librarian
npm init -y
npm install express knex sqlite3 body-parser express-validator
npm install --save-dev nodemon
- Express: A minimal web framework for Node.js.
- Knex: SQL query builder for handling database queries.
- SQLite3: A simple relational database for this use case.
- Express-validator: For request validation.
- Nodemon: Automatically restarts the server on file changes
npx knex migrate:make create_users --knexfile ./config/knexfile.js
npx knex migrate:make create_books --knexfile ./config/knexfile.js
npx knex migrate:make create_borrowed_books --knexfile ./config/knexfile.js
- Permissions:
chmod -R 755 db/
- After defining migrations
npx knex migrate:latest --knexfile ./config/knexfile.js
npm run dev (developer mode)
### Build Docker Image
docker build -t librarian .
docker run -p 3000:3000 -v $(pwd)/db:/usr/src/app/db librarian
The API is documented using Postman. The Postman Collection is located in the API Collection
folder.
GET /users
: Retrieve all usersPOST /users
: Create a new userGET /books
: Retrieve all booksPOST /users/:userId/borrow/:bookId
: Borrow a bookPOST /users/:userId/return/:bookId
: Return a book
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch
- Commit your changes:
git commit -m 'Add new feature'
- Push to the branch:
git push origin feature-branch
- Create a new Pull Request