2) REST API (backend, optional)
Base URL: http://localhost:3001/api
- Normally requires JWT auth (Authorization: Bearer …)
- Allowed roles:
manager, instructor, ta, fab_student
- Local demo auth bypass:
PLOTTER_AUTH_DISABLED=1
- Run without DB init for plotter-only demo:
PLOTTER_ONLY=1
GET /plotter/health
{
"status": "ok",
"plotter": {
"portPath": "/dev/ttyACM0",
"baudRate": 115200,
"isOpen": false
}
}
POST /plotter/command
Body:
{
"command": "PENUP",
"timeoutMs": 4000
}
Example response:
{
"sent": "PENUP",
"ok": true,
"terminalLine": "OK PEN_UP",
"lines": ["OK PEN_UP"]
}
POST /plotter/job
Runs multiple commands sequentially.
Body (script):
{
"script": "PENUP\nSPEED 1200\nMOVE X200 Y200\nPENDOWN\nMOVE X-200 Y-200\nPENUP",
"timeoutMs": 4000,
"stopOnError": true
}
Body (commands array):
{
"commands": ["PENUP", "SPEED 1200", "MOVE X200 Y200", "PENUP"],
"timeoutMs": 4000
}