For a full map of guides (this tab) and every API Reference section, see Introduction.
Prerequisites
- Node.js 18+
- MongoDB running locally or a remote connection string
Installation
Clone and install
git clone https://github.com/ContentsDigital-Lab/STD.Plus-ltd.git
cd STD.Plus-ltd
npm install
Configure environment
cp .env.example .env # if the repo provides it; otherwise create `.env` manually
Required variables are validated at startup (src/config/env.js). Set at least:| Variable | Default | Description |
|---|
NODE_ENV | development | Environment mode |
PORT | 3000 | Server port |
CORS_ORIGIN | * | Allowed CORS origin |
MONGODB_URI | — | MongoDB connection string |
JWT_SECRET | — | Secret key for signing JWTs |
JWT_EXPIRES_IN | 7d | JWT expiration time (see src/config/env.js) |
Seed the database
This creates a default admin worker:
- Username:
admin
- Password:
admin123
- Role:
admin
Start the server
# Development (with auto-reload)
npm run dev
# Production
npm start
Verify
curl http://localhost:3000/api/health
{
"success": true,
"message": "Success",
"data": {
"status": "healthy",
"uptime": 5,
"timestamp": "2026-03-07T12:00:00.000Z"
}
}
Scripts
# Reset the database (drops all collections)
npm run reset
# Seed the admin user and system roles
npm run seed
# Backfill auto-generated numbers for existing documents (requests, orders, claims, panes, withdrawals)
npm run backfill
# Migrate station references (string names → ObjectIds)
npm run migrate:stations
# Migrate worker roles (string → ObjectId) and seed system roles
npm run migrate:roles
# Default CI-style suite: scan → RBAC → integrity (requires API running)
npm test
# Test RBAC and permissions (includes pane logs, scan, orders, etc.)
npm run test:rbac
# Test pane scanning workflow
npm run test:scan
# Test claim and remake pane flow
npm run test:claim
# Test WebSocket events
npm run test:socket
# Test data integrity enforcement
npm run test:integrity
# Test pagination
npm run test:pagination
# Run Mintlify docs locally
npm run docs
Integration tests
npm test runs test:scan, then test:rbac, then test:integrity in that order. Other scripts (test:socket, test:pagination, test:claim) are separate.
All of these call the running HTTP API (same host/port as PORT in .env, default 3000). Start the server in another terminal before running them.
npm run test:integrity (and therefore npm test, which ends with it) issues many requests over several minutes. Keep npm run dev / npm start running for the whole run. If the server restarts or stops mid-suite (for example nodemon reload), you may see a network error or “Suite aborted” in the log; the integrity script still prints PASSED / FAILED totals and runs cleanup when possible.
The suite generates unique values where the API enforces uniqueness (for example worker usernames), and it sweeps new documents after the run when it can. If you still see 409 Conflict (duplicate username or similar), remove the conflicting document in MongoDB or run npm run reset on a database you are allowed to wipe — reset drops all collections.