Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BFHL REST API

REST API for Chitkara Qualifier - Implements POST /bfhl and GET /health endpoints.

Features

  • 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

Setup

1. Install Dependencies

npm install

2. Configure Environment Variables

Edit .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

3. Update Email

In index.js, update the OFFICIAL_EMAIL constant with your Chitkara email.

4. Run Locally

npm start

Server will run on http://localhost:3000

API Endpoints

GET /health

Returns health status.

Response:

{
  "is_success": true,
  "official_email": "your_email@chitkara.edu.in"
}

POST /bfhl

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"
}

Deployment

Vercel (Recommended)

  1. Push code to GitHub
  2. Go to https://vercel.com
  3. Import your GitHub repository
  4. Add environment variable: GEMINI_API_KEY
  5. Deploy

Railway

  1. Go to https://railway.app
  2. New Project → Deploy from GitHub
  3. Select repository
  4. Add environment variable: GEMINI_API_KEY
  5. Deploy

Render

  1. Go to https://render.com
  2. New Web Service → Connect repository
  3. Build command: npm install
  4. Start command: npm start
  5. Add environment variable: GEMINI_API_KEY
  6. Deploy

Testing Locally

# 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?"}'

Tech Stack

  • Node.js
  • Express.js
  • Google Gemini AI

About

qualifier 1

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages