The project is intended to manage a library to handle the users and storage.
- User account creation, login and updates
- Add Authors data and updates
- Add books and update storage amounts
- Advanced search in books with
fuzzySearchmaking use oftrigrams (pg_trgm)in PostgreSQL - Export data about borrowed books
- The application at this point allows authentication using
passportandjwtStrategy - The application at this point allows rate limiting using
redisas the cache to allow for scaling (as the app can be deployed on multiple instances)
- Requires Node.js (Preferred v20)
- PostgreSQL (Preferred v14.5)
- Redis (Preferred v6.0)
- The application date is located in .env file based on you environment and database name, ..etc.
# Sample env
# Running Application Env Variables
PORT=3500
# Database URI
POSTGRES_URI=postgres://postgres:someStrongPassword@localhost:5432/library_management_system
# Test Database URI
POSTGRES_TEST_URI=postgres://postgres:someStrongPassword@localhost:5432/library_management_system_test
# REDIS CONNECTION URI
REDIS_URI=redis://localhost:6379
# Database URI FOR DOCKER
POSTGRES_URI=postgres://postgres:someStrongPassword@postgres:5432/library_management_system
# REDIS CONNECTION URI FOR DOCKER
REDIS_URI=redis://redis:6379
# Hash pepper
HASH_PEPPER=mv2@$$o3n6va&^aff!^s2nvk74&9g7byse*
# Passport Authentication Secret
JWT_SECRET=piwx@&!o3n6v158@13aswvk74&9g7bw*wbb
- For ease of usage the application is dockerized and can be run instantly using
npm run dev:docker
-
Required:
- Create testing database based on the name of your env for example
library_management_system_test - It is better to create the extension through database rather than sequelize so run
CREATE EXTENSION IF NOT EXISTS pg_trgm; - For Docker Run these commands:
docker exec -it library-management-system-postgres psql -U postgres -c "CREATE DATABASE library_management_system_test;" docker exec -it library-management-system-postgres psql -U postgres -d library_management_system_test -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" - Create testing database based on the name of your env for example
-
For testing you can use the script
npm run test -- {filePath}
- The endpoints are documented with swagger on
http://localhost:3500/docs/api/=> modify port based on your environment - JSON collection for postman(via import) can also be found here.
