A simple and efficient backend API for a collaborative whiteboard app, built with Node.js, Express, and MongoDB. Includes comprehensive unit and integration testing using Vitest and Supertest.
- 📄 Create whiteboards with a title and creator name
- 🔍 Retrieve a whiteboard by its ID
- ❌ Delete a whiteboard by ID
- 🧪 Tested routes using Supertest and Vitest
- 🧱 Clean, modular code with
app.js
,models
, androutes
structure - 🔐 Ready for integration with authentication (e.g. JWT)
The API has been tested using:
Vitest
for test runnerSupertest
for simulating HTTP requestsMongoose
uses separate test database to avoid messikng with live data.
npm test
## Technologies Used
- **Express.js** — Backend framework for handling routes and middleware
- **MongoDB & Mongoose** — Database and ORM for storing whiteboard data and users
- **Vite** — (Frontend-ready) Build tool for fast front-end development
- **Vitest** — Unit testing framework for JavaScript & TypeScript
- **Supertest** — HTTP assertions for API endpoint testing
- **bcrypt** — Password hashing
- **dotenv** — Environment variable management
## API Endpoints
### User Routes (`/api/users`)
- `POST /register` — Register a new user
- `POST /login` — Authenticate user and return JWT
- `PUT /update-password` — Update user password (requires valid JWT)
- `DELETE /delete-account/:id` — Delete a user by ID
### Whiteboard Routes (`/api/whiteboard`)
- `POST /` — Create a new whiteboard
- `GET /:id` — Get a whiteboard by ID
- `DELETE /:id` — Delete a whiteboard by ID
## Test Coverage
✅ User route tests for:
- Registration
- Login
- Password update
- User deletion
✅ Whiteboard route tests for:
- Creating a whiteboard
- Fetching by ID
- Deletion
## Getting Started
```bash
# Clone the repository
git clone https://github.com/jassakoch/whiteboard
# Navigate into the project directory
cd whiteboard-backend
# Install dependencies
npm install
# Start the development server
npm run dev