A clean and lightweight Node.js + Express API for StudyNook — a modern study-room booking platform.
✨ What is StudyNook Server?
StudyNook Server is the backend API powering the StudyNook platform. It handles room listings, booking management, conflict detection, and JWT-based authentication — all deployed serverlessly on Vercel with MongoDB as the database.
Feature
Description
🏠 Room Management
Browse, search, filter, create, update, and delete rooms
📅 Booking System
Create bookings with automatic conflict detection
🔐 Authentication
JWT verification using remote JWKS
👤 Owner Listings
Fetch and manage listings by authenticated users
🛡️ Security
Protected routes with CORS configured for secure cross-origin requests
☁️ Serverless
Production-grade deployment on Vercel with MongoDB integration
Category
Technology
Runtime
Node.js 18+
Framework
Express.js
Database
MongoDB
Authentication
JWT + JWKS
Middleware
CORS, dotenv
Deployment
Vercel (Serverless)
Method
Route
Description
Auth
GET
/rooms
Get all rooms (supports search & amenities query params)
Public
GET
/rooms/:id
Get single room with booking count
Public
GET
/featured-rooms
Get up to 6 featured rooms
Public
POST
/rooms
Create a new room
🔒 Protected
PATCH
/rooms/:id
Update a room
🔒 Protected
DELETE
/rooms/:id
Delete a room
🔒 Protected
Method
Route
Description
Auth
POST
/booking
Create a booking (with conflict detection)
🔒 Protected
GET
/bookings
Get bookings (supports userId query param)
Public
PATCH
/booking/:id/cancel
Cancel a booking
🔒 Protected
Method
Route
Description
Auth
GET
/my-listings
Get listings by the authenticated user
🔒 Protected
Method
Route
Description
GET
/
Server status check
All protected routes require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_TOKEN_HERE
Protected routes: POST /rooms, PATCH /rooms/:id, DELETE /rooms/:id, POST /booking, PATCH /booking/:id/cancel, GET /my-listings
Create a .env file in the root directory:
PORT = 5000
MONGODB_URI = mongodb+srv://<username>:<password>@<cluster>.mongodb.net/<database>
CLIENT_URL = http://localhost:3000
Variable
Type
Description
Example
PORT
Number
Server listening port
5000
MONGODB_URI
String
MongoDB connection string
mongodb+srv://...
CLIENT_URL
String
Frontend URL for JWKS verification
http://localhost:3000
git clone https://github.com/Saharier36/studynook-server
cd studynook-server
Then open: http://localhost:5000
Script
Description
npm run dev
Start development server
npm start
Run production server
study-nook-server/
├── index.js # Main Express server & all API routes
├── package.json # Dependencies & scripts
├── vercel.json # Vercel deployment configuration
└── README.md # Project documentation
Package
Version
express
^5.2.1
mongodb
^7.2.0
cors
^2.8.6
dotenv
^17.4.2
jose-cjs
^6.2.3
The project is ready for Vercel deployment with the included vercel.json.
Entry file: index.js
Serverless handler: @vercel/node
Collections used: rooms, bookings, user
StudyNook Server is built for reliability — with conflict-safe bookings, secure JWT auth, and a clean REST API design.