/**
* Gauntlet-Incept main entry point
*
* This file serves as the main entry point for the Gauntlet-Incept project,
* which aims to generate high-quality educational content tailored to
* students' knowledge levels and interests.
*/
// Import required modules
const express = require('express');
const dotenv = require('dotenv');
// Import API routes
const questionRoutes = require('./api/questionRoutes');
const articleRoutes = require('./api/articleRoutes');
// Load environment variables
dotenv.config();
// Initialize Express app
const app = express();
const port = process.env.PORT || 3000;
// Middleware
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// API Routes
app.use('/api/question', questionRoutes);
app.use('/api/article', articleRoutes);
// Root route
app.get('/', (req, res) => {
res.json({
message: 'Welcome to the Gauntlet-Incept API',
documentation: '/api/docs',
version: '0.1.0'
});
});
/**
* Start the server
*
* This function initializes the Express server and starts listening
* for incoming requests.
*/
function startServer() {
app.listen(port, () => {
console.log(`Gauntlet-Incept API server running on port ${port}`);
});
}
// Start the server if this file is run directly
if (require.main === module) {
startServer();
}
// Export for testing
module.exports = { app, startServer };