Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

49 changes: 49 additions & 0 deletions CONFIG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# SipMap Configuration Guide

## 🔑 API Key Management

### Single Source of Truth
The application uses **ONE** configuration file for the Google Maps API key:

```
📁 SipMap/
└── .env ← YOUR API KEY GOES HERE (ONLY PLACE TO CHANGE IT)
```

### How to Update Your API Key

1. **Open the file**: `/Users/mehalsrivastava/GitHub/SipMap/.env`
2. **Update the key**: Change `GOOGLE_MAPS_API_KEY=your_current_key` to your new key
3. **Restart the server**: The server will automatically pick up the new key

### Example .env file:
```bash
GOOGLE_MAPS_API_KEY=AIzaSyAOFpadsj8FUVZatR4TpCtr2gTCcEdOTAY
PORT=3000
NODE_ENV=production
```

## 🔄 Quick Restart Commands

When you change the API key, restart the server:

```bash
# Stop any running server
pkill -f "node server.js"

# Start the server
cd /Users/mehalsrivastava/GitHub/SipMap/server && node server.js
```

## ✅ Verification

After updating the API key:
1. Check server logs show: `API Key loaded successfully`
2. Test a search in your browser at `http://localhost:5500`
3. Verify API calls return restaurant/cafe data

## 🚨 Important Notes

**No more duplicate .env files** - Server reads from root `.env` only
- **One place to change API key** - Only edit `/SipMap/.env`
- **Version control** - The `.env` file is gitignored for security
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ Option B — Serve locally (recommended):
python3 -m http.server (any portnum of your choice)
```

## 🔧 Configuration (optional)
If you use a backend or API keys, copy `.env.example` to `.env` and fill in values. The front‑end reads from your environment only if you wire a server or bundler that injects them.
## 🔧 Configuration

- `.env.example` — reference for required variables
### 🔑 API Key Setup (Simplified)

**One place to manage your API key:** Edit the `.env` file in the root directory

1. **Edit `.env`**: Replace `your_google_maps_api_key_here` with your actual API key
2. **Restart server**: If running the backend, restart to pick up changes

See `CONFIG.md` for detailed instructions.

### Google Cloud Setup

- Set up your project in the Google Cloud Console. You'll enter a project name and billing information. Your website won't work as it should unless you enable billing, but you won't be charged if the API doesn't get called past the monthly limit (we'll teach you how to cap it at the limit, which is usually 10,000 API calls).

Expand Down
5 changes: 4 additions & 1 deletion server/server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const express = require('express');
const cors = require('cors');
const fetch = require('node-fetch');
require('dotenv').config();
const path = require('path');

// Configure dotenv to read from the root project directory
require('dotenv').config({ path: path.join(__dirname, '..', '.env') });

// Middleware to log request details
const logRequestDetails = (req, res, next) => {
Expand Down