Express REST API implementing user signup, duplicate validation, and user retrieval with documented Postman/curl tests.
A simple REST API built with Node.js and Express. It supports user signup, fetching users by ID, and a demo protected route.
- Node.js
- Express
- CORS
- In-memory storage (no database yet)
-
Install dependencies: npm install
-
Start server: node server.js
Server runs on: http://localhost:8000
POST /signup
Creates a new user account.
Request Body (JSON): { "username": "triphon", "email": "[email protected]", "password": "1234" }
Success Response: 201 Created { "message": "User triphon registered successfully", "data": { "id": 1, "username": "triphon", "email": "[email protected]" } }
Errors:
- 400 Missing fields
- 409 Email already registered
GET /users/:id
Example: GET http://localhost:8000/users/1
Response: { "id": 1, "username": "triphon", "email": "[email protected]", "createdAt": "2026-02-24T10:00:00.000Z" }
Errors:
- 400 Invalid ID
- 404 User not found
GET /secret?user=triphon
Returns a message only if username matches "triphon".
- Method: POST
- URL: http://localhost:8000/signup
- Headers: Content-Type: application/json
- Body: raw JSON
curl -X POST http://localhost:8000/signup
-H "Content-Type: application/json"
-d "{"username":"triphon","email":"[email protected]","password":"1234"}"
- Users stored in memory (reset on server restart)
- No real password hashing yet
- No database persistence
Future: MongoDB / SQL integration