LifeMate — Personal, Family & Learning Companion

phase-4/ai-learning-wellbeing
chore/phase1-repository-cleanup deploy/stable-web-apk deployment-static design/mobile-accessibility-v2 design/mobile-navigation-review docs/child-education-access-decision docs/offline-data-rescue-options docs/owner-guide-and-delivery-plan docs/phase1-policy-options docs/public-review-live-2026-10-15 feat/aparat-learning-library feat/child-device-safety feat/child-identity-schema feat/flutter-mobile-navigation feat/learning-content-operations feat/local-signing-preflight feat/online-family-stage0 feat/personal-encrypted-recovery feat/private-planner-series-api feat/public-review-page feat/standalone-weekly-planner feat/weekly-planner-android final-feature-1/iran-family-school fix/auth-abuse-expiry-safety fix/auth-expiry-after-lock fix/backend-request-safety fix/lifeguide-bootstrap-naming-ci fix/lifeguide-pages-qa-base-preflight fix/lifeguide-qa-pages-env-deployment fix/local-task-persistence fix/managed-child-session-boundary fix/personal-jalali-dates fix/personal-notification-controls fix/personal-upgrade-delivery-guard fix/sms-approval-gates fix/study-duration-display infra/cloudflare-neon-migration infra/lifeguide-cloudflare-qa infra/lifeguide-github-pages-qa infra/lifeguide-supabase-qa main phase-1/foundation-completion phase-2/product-foundation-identity phase-3/planner-school-family-core phase-4/ai-learning-wellbeing phase-5/hardening-observability-release test/android-reminder-acceptance test/personal-notification-settings test/personal-recovery-acceptance test/role-entry-apk
js 9 lines 895 Bytes
Raw
1 process.env.NODE_ENV = 'test';
2 const { app, pool } = await import('./server.js');
3 const { createPhase4Router } = await import('./phase4.js');
4 import jwt from 'jsonwebtoken';
5 const jwtSecret=process.env.JWT_SECRET;
6 async function auth(req,res,next){const raw=req.headers.authorization?.replace(/^Bearer\s+/i,'');try{const identity=jwt.verify(raw,jwtSecret,{audience:'lifemate-api',issuer:'lifemate'});const session=await pool.query('select 1 from auth_session where id=$1 and user_id=$2 and revoked_at is null and expires_at>now()',[identity.sid,identity.sub]);if(!session.rowCount)return res.status(401).json({error:'session_invalid'});req.identity=identity;next()}catch{return res.status(401).json({error:'unauthorized'})}}
7 app.use('/v1',createPhase4Router({pool,auth}));
8 const port=Number(process.env.PORT??8080);
9 app.listen(port,()=>console.log(`LifeMate API Phase 4 listening on ${port}`));