Skip to content

Latest commit

Β 

History

History
114 lines (78 loc) Β· 2.79 KB

File metadata and controls

114 lines (78 loc) Β· 2.79 KB

✍️ Eraser - Backend (version-1) βœ… (Completed)

This is the backend server for Eraser, a real-time collaborative whiteboard app. Built using Node.js, Express, Prisma ORM, and SQLite for local development.

βœ… Features – Version 1 (Completed) πŸ” Authentication (Test Only – No Login) No login, no user registration, and no real profiles.

A test JWT token is manually used to access protected routes.

Use jwt.io to generate a token with a test payload like:

json Copy Edit { "userId": "test-user-123" } Include the token in the Authorization header as:

http Copy Edit Authorization: Bearer <your_token> ⚠️ This is for local development/testing only. No user data is stored.

🧩 Board Management POST /boards – Create a new board (with optional title)

GET /boards – List all boards of the test user

GET /boards/:id – Fetch a specific board by ID

PATCH /boards/:id – Rename a board

DELETE /boards/:id – Soft delete a board

πŸ–ŠοΈ Stroke Management POST /boards/:id/strokes – Save strokes (XY point data) for a board

GET /boards/:id/strokes – Retrieve all strokes for a given board

πŸ™‹ Current User GET /me – Returns test user info from JWT payload

πŸ—„οΈ Database (SQLite via Prisma) Tables:

boards (includes soft delete, title, userId)

strokes (includes points, boardId)

No users table is used in v1.

Uses SQLite (dev.db) locally β€” can be swapped with PostgreSQL later.

πŸ“¦ Tech Stack Node.js + Express

Prisma ORM

SQLite (for development)

JWT (test-only, no real auth)

🚧 Real-time sync is not included in v1 Real-time drawing synchronization (Yjs + WebSocket server) will be introduced in v2.

πŸ§ͺ Setup Instructions bash Copy Edit

1. Install dependencies

npm install

2. Setup .env

Add a JWT_SECRET used to decode test tokens

set JWT_SECRET

3. Generate Prisma client & migrate

npx prisma migrate dev --name init

4. Run dev server

npm run dev

🌐 Frontend Integration

In your Vite frontend .env file: VITE_API_URL=http://localhost:5000

Use it like this in your frontend code: const apiUrl = import.meta.env.VITE_API_URL;

fetch(${apiUrl}/boards, { headers: { Authorization: Bearer <your_test_jwt_token>, }, });

Method Route Description
GET /me Get test user info
POST /boards Create new board
GET /boards List all boards (test user)
GET /boards/:id Get a board by ID
PATCH /boards/:id Rename a board
DELETE /boards/:id Soft delete a board
POST /boards/:id/strokes Save drawing strokes
GET /boards/:id/strokes Get all strokes for a board