This project is the final assignment for the CT449 Web Application Development course.
The Bookery is an online platform designed to streamline library management and improve the user experience for borrowing books. This repository contains the backend codebase for the system.
Check out: The Bookery (Client)
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (with Prisma ORM)
- Authentication: Passport.js with JWT and Local Strategies
- Validation: zod, express-validator, class-validator and class-transformer
- Node.js (v16 or later recommended)
- MongoDB instance (local or cloud-based, e.g., MongoDB Atlas)
- npm or yarn package manager
git clone https://github.com/bp82125/thebookery-server.git
cd thebookery-servernpm install
# or
yarn install- Install MongoDB locally or create a cluster using MongoDB Atlas.
- Obtain your MongoDB connection URI (e.g.,
mongodb+srv://<username>:<password>@cluster.mongodb.net/<dbname>?retryWrites=true&w=majority). - Ensure the
DATABASE_URLin your .env file matches the connection URI you obtained.
To enable media upload and storage with Cloudinary, you’ll need the following credentials:
cloud_nameapi_keyapi_secretupload_preset
-
Sign Up or Log In:
- Go to Cloudinary and sign up or log in.
-
Get Cloud Name, API Key, and API Secret:
- After logging in, go to your Cloudinary Dashboard.
- Under Account Details, copy the following:
- Cloud Name
- API Key
- API Secret
-
Create an Upload Preset:
- Go to Settings > Upload tab.
- Scroll down to the Upload Presets section.
- Click Add upload preset.
- Configure the preset:
- Enable unsigned uploads if you want client-side uploads (from frontend).
- Optionally configure folder, allowed formats, transformations, etc.
- Save and copy the Upload Preset Name.
Copy the .env.example file to create your .env file:
cp .env.example .envUpdate the .env file with the necessary values:
# MongoDB connection URI (for local or MongoDB Atlas)
DATABASE_URL="mongodb+srv://<username>:<password>@cluster.mongodb.net/<dbname>?retryWrites=true&w=majority"
# Cloudinary credentials (refer to the values you obtained in step 4)
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
CLOUDINARY_UPLOAD_PRESET=your_upload_preset
# JWT configuration
JWT_SECRET=your_jwt_secret
JWT_EXPIRE_IN=1h
# Admin credentials (used to log into the system)
ADMIN_USERNAME=admin
ADMIN_PASSWORD=your_secure_passwordnpx prisma generatePrisma requires MongoDB to run as a replica set to support transactions.
If you're using a local MongoDB instance, you can follow this workaround to set up a single-node replica set.
npm start
# or
yarn startThe server will run at http://localhost:5000 by default.
Prisma Migrations: To apply database schema changes:
npx prisma migrate devLinting: Ensure code quality with ESLint:
npm run lint
# or
yarn lintThis project is licensed under the MIT License. See the LICENSE file for details.