Files
website-monitor/frontend/lib/auth.ts
Timo 2c1ec69a79 Initial implementation of Website Change Detection Monitor MVP
Features implemented:
- Backend API with Express + TypeScript
- User authentication (register/login with JWT)
- Monitor CRUD operations with plan-based limits
- Automated change detection engine
- Email alert system
- Frontend with Next.js + TypeScript
- Dashboard with monitor management
- Login/register pages
- Monitor history viewer
- PostgreSQL database schema
- Docker setup for local development

Technical stack:
- Backend: Express, TypeScript, PostgreSQL, Redis (ready)
- Frontend: Next.js 14, React Query, Tailwind CSS
- Database: PostgreSQL with migrations
- Services: Page fetching, diff detection, email alerts

Documentation:
- README with full setup instructions
- SETUP guide for quick start
- PROJECT_STATUS with current capabilities
- Complete technical specifications

Ready for local testing and feature expansion.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-16 18:46:40 +01:00

30 lines
639 B
TypeScript

export function saveAuth(token: string, user: any) {
localStorage.setItem('token', token);
localStorage.setItem('user', JSON.stringify(user));
}
export function getAuth() {
if (typeof window === 'undefined') return null;
const token = localStorage.getItem('token');
const userStr = localStorage.getItem('user');
if (!token || !userStr) return null;
try {
const user = JSON.parse(userStr);
return { token, user };
} catch {
return null;
}
}
export function clearAuth() {
localStorage.removeItem('token');
localStorage.removeItem('user');
}
export function isAuthenticated() {
return !!getAuth();
}