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

1

Clone and install

git clone https://github.com/ContentsDigital-Lab/STD.Plus-ltd.git
cd STD.Plus-ltd
npm install
2

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:
VariableDefaultDescription
NODE_ENVdevelopmentEnvironment mode
PORT3000Server port
CORS_ORIGIN*Allowed CORS origin
MONGODB_URIMongoDB connection string
JWT_SECRETSecret key for signing JWTs
JWT_EXPIRES_IN7dJWT expiration time (see src/config/env.js)
3

Seed the database

npm run seed
This creates a default admin worker:
  • Username: admin
  • Password: admin123
  • Role: admin
4

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.