Build a complete authentication API with registration, login, and a protected route.
Endpoints:
| Method | Path | Description |
|---|---|---|
| POST | /register | Hash password, store user in-memory, return { id, email } |
| POST | /login | Verify password, return signed JWT |
| GET | /me | Verify JWT from Authorization: Bearer <token> header, return user info |
Requirements:
"nextsecret", expires in "1h"POST /register with existing email → 409 { error: "Email already registered" }POST /login with wrong credentials → 401 { error: "Invalid credentials" }GET /me without or with invalid token → 401 { error: "Unauthorized" }"Auth API ready" on start then close.Build a complete authentication API with registration, login, and a protected route.
Endpoints:
| Method | Path | Description |
|---|---|---|
| POST | /register | Hash password, store user in-memory, return { id, email } |
| POST | /login | Verify password, return signed JWT |
| GET | /me | Verify JWT from Authorization: Bearer <token> header, return user info |
Requirements:
"nextsecret", expires in "1h"POST /register with existing email → 409 { error: "Email already registered" }POST /login with wrong credentials → 401 { error: "Invalid credentials" }GET /me without or with invalid token → 401 { error: "Unauthorized" }"Auth API ready" on start then close.