A RESTful API for a movie blind test game where users can test their film knowledge through interactive quizzes.
- User authentication (register/login) with JWT
- Random movie questions from predefined categories
- Score tracking and leaderboard system
- Integration with TMDB (The Movie Database) API
- RESTful API endpoints for game interaction
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB with Mongoose
- Authentication: JWT (JSON Web Tokens)
- External API: TMDB (The Movie Database)
Before you begin, ensure you have the following installed:
- Node.js (v14 or higher)
- MongoDB
- npm or yarn
- TMDB API key
-
Clone the repository
git clone https://github.com/yourusername/film-blind-test-api.git cd film-blind-test-api
-
Install dependencies
npm install
-
Environment setup
cp .env.example .env
Then edit
.env
with your configuration:- Set your MongoDB URI
- Add your TMDB API key
- Configure JWT secret
-
Seed the database
node scripts/seed.js
-
Start the server
npm start
POST /auth/register
- Register a new userPOST /auth/login
- Login and receive JWT tokenPOST /auth/refresh
- Get new access token using refresh tokenPOST /auth/logout
- Logout and invalidate refresh token
GET /question
- Get a random questionGET /question/:id
- Get answer for specific question
POST /scores/score
- Submit a scoreGET /scores
- Get leaderboard
GET /user
- Get user profile informationGET /user/scores
- Get user's game historyPUT /user
- Update user profileDELETE /user
- Delete user account
- Create a new POST request to
http://localhost:3000/scores/score
- Add headers:
Authorization: Bearer your_access_token Content-Type: application/json
- Add body:
{ "score": 100 }
Required environment variables in .env
:
PORT=3000
NODE_ENV=development
MONGODB_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=24h
TMDB_API_KEY=your_tmdb_api_key
TMDB_API_URL=https://api.themoviedb.org/3
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.