128 lines
2.5 KiB
Markdown
128 lines
2.5 KiB
Markdown
|
|
# spotlight.cam Backend
|
||
|
|
|
||
|
|
Node.js + Express backend for spotlight.cam - P2P video exchange app for dance events.
|
||
|
|
|
||
|
|
## Features
|
||
|
|
|
||
|
|
- ✅ Express REST API
|
||
|
|
- ✅ CORS enabled
|
||
|
|
- ✅ Health check endpoint
|
||
|
|
- ✅ Error handling
|
||
|
|
- ✅ Unit tests (Jest + Supertest)
|
||
|
|
- ⏳ PostgreSQL integration (planned)
|
||
|
|
- ⏳ JWT authentication (planned)
|
||
|
|
- ⏳ Socket.IO for real-time chat (planned)
|
||
|
|
- ⏳ WebRTC signaling (planned)
|
||
|
|
|
||
|
|
## API Endpoints
|
||
|
|
|
||
|
|
### Health Check
|
||
|
|
- `GET /api/health` - Backend health status
|
||
|
|
|
||
|
|
### Future Endpoints
|
||
|
|
- `POST /api/auth/register` - Register new user
|
||
|
|
- `POST /api/auth/login` - Login user
|
||
|
|
- `GET /api/users/me` - Get current user
|
||
|
|
- `GET /api/events` - List events
|
||
|
|
- `POST /api/matches` - Create match
|
||
|
|
- `POST /api/ratings` - Rate partner
|
||
|
|
|
||
|
|
## Development
|
||
|
|
|
||
|
|
### Install dependencies
|
||
|
|
```bash
|
||
|
|
npm install
|
||
|
|
```
|
||
|
|
|
||
|
|
### Run in development mode
|
||
|
|
```bash
|
||
|
|
npm run dev
|
||
|
|
```
|
||
|
|
|
||
|
|
### Run tests
|
||
|
|
```bash
|
||
|
|
npm test
|
||
|
|
```
|
||
|
|
|
||
|
|
### Run tests in watch mode
|
||
|
|
```bash
|
||
|
|
npm run test:watch
|
||
|
|
```
|
||
|
|
|
||
|
|
### Run in production mode
|
||
|
|
```bash
|
||
|
|
npm start
|
||
|
|
```
|
||
|
|
|
||
|
|
## Environment Variables
|
||
|
|
|
||
|
|
Create a `.env` file (see `.env.example`):
|
||
|
|
|
||
|
|
```env
|
||
|
|
NODE_ENV=development
|
||
|
|
PORT=3000
|
||
|
|
CORS_ORIGIN=http://localhost:8080
|
||
|
|
```
|
||
|
|
|
||
|
|
## Project Structure
|
||
|
|
|
||
|
|
```
|
||
|
|
backend/
|
||
|
|
├── src/
|
||
|
|
│ ├── __tests__/ # Unit tests
|
||
|
|
│ │ └── app.test.js
|
||
|
|
│ ├── routes/ # API routes (future)
|
||
|
|
│ ├── controllers/ # Business logic (future)
|
||
|
|
│ ├── middleware/ # Custom middleware (future)
|
||
|
|
│ ├── utils/ # Helper functions (future)
|
||
|
|
│ ├── app.js # Express app setup
|
||
|
|
│ └── server.js # Server entry point
|
||
|
|
├── .env # Environment variables (gitignored)
|
||
|
|
├── .env.example # Environment variables template
|
||
|
|
├── package.json
|
||
|
|
└── Dockerfile
|
||
|
|
```
|
||
|
|
|
||
|
|
## Testing
|
||
|
|
|
||
|
|
Tests are written using:
|
||
|
|
- **Jest** - Test framework
|
||
|
|
- **Supertest** - HTTP assertions
|
||
|
|
|
||
|
|
Run tests:
|
||
|
|
```bash
|
||
|
|
npm test
|
||
|
|
```
|
||
|
|
|
||
|
|
Current test coverage:
|
||
|
|
- Health check endpoint
|
||
|
|
- 404 error handling
|
||
|
|
- CORS configuration
|
||
|
|
- JSON body parsing
|
||
|
|
|
||
|
|
## Docker
|
||
|
|
|
||
|
|
Build and run with Docker Compose (from project root):
|
||
|
|
```bash
|
||
|
|
docker compose up --build
|
||
|
|
```
|
||
|
|
|
||
|
|
Backend will be available at:
|
||
|
|
- Internal: http://backend:3000
|
||
|
|
- Through nginx: http://localhost:8080/api
|
||
|
|
|
||
|
|
## Next Steps
|
||
|
|
|
||
|
|
1. ✅ Basic Express setup
|
||
|
|
2. ✅ Health check endpoint
|
||
|
|
3. ✅ Unit tests
|
||
|
|
4. ⏳ PostgreSQL connection
|
||
|
|
5. ⏳ Database schema and migrations
|
||
|
|
6. ⏳ Authentication (JWT + bcrypt)
|
||
|
|
7. ⏳ Socket.IO for real-time chat
|
||
|
|
8. ⏳ WebRTC signaling
|
||
|
|
|
||
|
|
## License
|
||
|
|
|
||
|
|
TBD
|