pulsebackend
v0.6.0
Published
A secure Node.js, Express, and Prisma API for the Pulse wellness tracker.
Readme
PulseBackEnd
A secure Node.js, Express, and Prisma API for the Pulse wellness tracker.
Features
- TypeScript development with
ts-node - JWT-based user authentication
- HTTPS server with bundled certificates
- CRUD check-in endpoints for moods, emotions, sleep, health items, hobbies, social activities, chores, productivity, and weather
- Analytics endpoints for mood trends, emotion clouds, sleep trends, productivity trends, and item frequency clouds
- PostgreSQL schema defined with Prisma
- Per-user data access enforced in code
.envconfiguration for secrets and database connection
Setup
- Install dependencies with
npm install. - Create a
.envfile and defineDATABASE_URL,JWT_SECRET, andPORT. - Push the schema to your database with
npx prisma db push. - Start the development server with
npm run dev. For production, runnpm run buildthennpm start.
Database Schema
The full schema resides in prisma/schema.prisma. It creates tables for
users, check-ins, and all related metadata enums.
API Endpoints
POST /api/auth/register– Register a new userPOST /api/auth/login– Login and receive a JWTGET /api/checkins– Retrieve check-ins for the authenticated userPOST /api/checkins– Add a new check-inGET /api/analytics/mood-trend– Mood scores over timeGET /api/analytics/emotion-cloud– Emotion frequency for a date rangeGET /api/analytics/sleep-trend– Sleep quality trendGET /api/analytics/productivity-trend– Productivity trendGET /api/analytics/health-cloud– Health item frequencyGET /api/analytics/hobby-cloud– Hobby frequencyGET /api/analytics/social-cloud– Social interaction frequencyGET /api/analytics/chore-cloud– Chore frequencyGET /api/analytics/weather-cloud– Weather condition frequency
Security
All endpoints except register and login require a valid JWT. The server isolates user data based on the token payload, and secrets remain in the server environment.
