Express + MongoDB (Mongoose) API for tracking personal health metrics and their recorded values.
- Node.js 16+
- MongoDB (local or Atlas)
npm install
cp .env.example .env # then fill in the values
npm run dev # start with nodemon
# or
npm start # start with nodenpm run dev— start with nodemonnpm start— start the servernpm test— run the mocha test suite
See .env.example. Required: TOKEN_SECRET, MONGODB_URI_PRODUCTION.
All non-auth routes require an x-auth-token header (see Authentication).
| Method | Path | Description |
|---|---|---|
| POST | /api/auth/register |
Register and receive a token |
| POST | /api/auth/login |
Log in and receive a token |
| GET | /api/auth/loadUser |
Current user |
| GET/POST/PUT/DELETE | /api/metrics |
Manage metric definitions |
| POST/PUT/GET/DELETE | /api/metrics/wage |
Manage recorded metric values |
| GET/POST/PUT/DELETE | /api/group |
Manage metric groups |
Stateless JWT in the x-auth-token header. Payload: { user: { id } }, signed with TOKEN_SECRET, expiring after TOKEN_EXPIRY (default 5 days).