REST API for user authentication built with Node.js, Express, JWT, and SQLite.
Part of a full-stack project — see the React frontend.
- Node.js + Express 5
- SQLite via better-sqlite3
- JWT (jsonwebtoken) — 7-day token expiry
- bcryptjs — password hashing with salt rounds
- dotenv for environment config
npm installCreate a .env file:
JWT_SECRET=your_secret_here
PORT=5001
Start the server:
npm run dev # development (nodemon)
npm start # productionServer runs on http://localhost:5001
| Method | Route | Description |
|---|---|---|
POST |
/api/auth/register |
Register a new user |
POST |
/api/auth/login |
Login and receive JWT |
GET |
/api/auth/me |
Verify token |
GET |
/api/auth/profile |
Get full user profile |
POST |
/api/auth/logout |
Logout (client-side token removal) |
Protected routes require:
Authorization: Bearer <token>
SQLite — auto-created on first run as auth.db.
users (id, username, email, password, role, created_at)Roberto Feliciano · CS Student · UIPR Ponce
github.com/rrobertf