REST API for Chitkara Qualifier - Implements POST /bfhl and GET /health endpoints.
- POST /bfhl - Handles fibonacci, prime, lcm, hcf, and AI queries
- GET /health - Health check endpoint
- Input validation and error handling
- Google Gemini AI integration for AI queries
npm installEdit .env file and add your Gemini API key:
GEMINI_API_KEY=your_gemini_api_key_here
Get your free API key from: https://aistudio.google.com
In index.js, update the OFFICIAL_EMAIL constant with your Chitkara email.
npm startServer will run on http://localhost:3000
Returns health status.
Response:
{
"is_success": true,
"official_email": "your_email@chitkara.edu.in"
}Process one of: fibonacci, prime, lcm, hcf, AI
Fibonacci Example:
// Request
{ "fibonacci": 7 }
// Response
{
"is_success": true,
"official_email": "...",
"data": [0, 1, 1, 2, 3, 5, 8]
}Prime Example:
// Request
{ "prime": [2, 4, 7, 9, 11] }
// Response
{
"is_success": true,
"official_email": "...",
"data": [2, 7, 11]
}LCM Example:
// Request
{ "lcm": [12, 18, 24] }
// Response
{
"is_success": true,
"official_email": "...",
"data": 72
}HCF Example:
// Request
{ "hcf": [24, 36, 60] }
// Response
{
"is_success": true,
"official_email": "...",
"data": 12
}AI Example:
// Request
{ "AI": "What is the capital city of Maharashtra?" }
// Response
{
"is_success": true,
"official_email": "...",
"data": "Mumbai"
}- Push code to GitHub
- Go to https://vercel.com
- Import your GitHub repository
- Add environment variable:
GEMINI_API_KEY - Deploy
- Go to https://railway.app
- New Project → Deploy from GitHub
- Select repository
- Add environment variable:
GEMINI_API_KEY - Deploy
- Go to https://render.com
- New Web Service → Connect repository
- Build command:
npm install - Start command:
npm start - Add environment variable:
GEMINI_API_KEY - Deploy
# Health check
curl http://localhost:3000/health
# Fibonacci
curl -X POST http://localhost:3000/bfhl -H "Content-Type: application/json" -d '{"fibonacci": 7}'
# Prime
curl -X POST http://localhost:3000/bfhl -H "Content-Type: application/json" -d '{"prime": [2,4,7,9,11]}'
# LCM
curl -X POST http://localhost:3000/bfhl -H "Content-Type: application/json" -d '{"lcm": [12,18,24]}'
# HCF
curl -X POST http://localhost:3000/bfhl -H "Content-Type: application/json" -d '{"hcf": [24,36,60]}'
# AI
curl -X POST http://localhost:3000/bfhl -H "Content-Type: application/json" -d '{"AI": "What is the capital of India?"}'- Node.js
- Express.js
- Google Gemini AI