Skip to content

MicrosoftStudentChapter/eraser-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✍️ 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •