Skip to content

Commit 4ae0ef6

Browse files
Merge pull request #547 from GitMetricsLab/revert-to-v1.0.2
Restore repository to v1.0.2 state
2 parents 3b5bcf0 + c203e21 commit 4ae0ef6

26 files changed

Lines changed: 856 additions & 2338 deletions

.env.example

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -41,206 +41,28 @@ Welcome to **GitHub Tracker**, a web app designed to help you monitor and analyz
4141
---
4242

4343
## 🚀 Setup Guide
44-
45-
### 📋 Prerequisites
46-
47-
Before setting up the project locally, ensure the following tools are installed on your system:
48-
49-
- Node.js (v18 or later recommended)
50-
- npm
51-
- Docker
52-
- Docker Compose
53-
- MongoDB (required for backend services and testing)
54-
55-
---
56-
57-
## 📥 Clone the Repository
58-
59-
```bash
60-
git clone https://github.com/GitMetricsLab/github_tracker.git
61-
cd github-tracker
62-
```
63-
64-
---
65-
66-
# 💻 Local Development Setup
67-
68-
This project contains both frontend and backend services.
69-
70-
## ▶️ Frontend Setup
71-
72-
Install frontend dependencies:
73-
74-
```bash
75-
npm install
76-
```
77-
78-
Start the frontend development server:
79-
80-
```bash
81-
npm run dev
82-
```
83-
84-
The frontend will run on:
85-
86-
```txt
87-
http://localhost:5173
88-
```
89-
90-
---
91-
92-
## ⚙️ Backend Setup
93-
94-
Move into the backend directory:
95-
44+
1. Clone the repository to your local machine:
9645
```bash
97-
cd backend
46+
$ git clone https://github.com/yourusername/github-tracker.git
9847
```
9948

100-
Install backend dependencies:
101-
49+
2. Navigate to the project directory:
10250
```bash
103-
npm install
51+
$ cd github-tracker
10452
```
10553

106-
3. Configure environment variables
107-
108-
Copy the example files and fill in your values:
109-
```bash
110-
# Frontend (.env in the repo root)
111-
cp .env.example .env
112-
113-
# Backend (.env inside backend/)
114-
cp backend/.env.example backend/.env
115-
```
116-
117-
Key variables to set:
118-
119-
| Variable | Where | Description |
120-
|---|---|---|
121-
| `VITE_BACKEND_URL` | root `.env` | URL of the backend (default: `http://localhost:5000`) |
122-
| `MONGO_URI` | `backend/.env` | MongoDB connection string |
123-
| `SESSION_SECRET` | `backend/.env` | Long random string used to sign session cookies |
124-
| `FRONTEND_ORIGIN` | `backend/.env` | URL of the frontend — restricts CORS. **Required in production.** Defaults to `http://localhost:5173` in development. |
125-
126-
4. Run the frontend
54+
3. Run the frontend
12755
```bash
128-
npm run dev
129-
```
130-
131-
The backend server will run on:
132-
133-
```txt
134-
http://localhost:5000
56+
$ npm i
57+
$ npm run dev
13558
```
13659

137-
5. Run the backend
60+
4. Run the backend
13861
```bash
139-
$ cd backend
14062
$ npm i
14163
$ npm start
14264
```
14365

144-
This command:
145-
146-
- Builds frontend and backend containers
147-
- Starts development services
148-
- Enables live file changes using Docker volumes
149-
- Runs frontend and backend simultaneously
150-
151-
### Development Services
152-
153-
| Service | Port |
154-
|----------|------|
155-
| Frontend | 5173 |
156-
| Backend | 5000 |
157-
158-
---
159-
160-
## 🚀 Production Environment
161-
162-
Run the production Docker setup:
163-
164-
```bash
165-
npm run docker:prod
166-
```
167-
168-
This command:
169-
170-
- Creates optimized production builds
171-
- Runs frontend using Nginx
172-
- Starts backend production services
173-
174-
### Production Services
175-
176-
| Service | Port |
177-
|----------|------|
178-
| Frontend | 3000 |
179-
| Backend | 5000 |
180-
181-
---
182-
183-
# 📂 Docker Configuration Overview
184-
185-
| File | Purpose |
186-
|------|----------|
187-
| `Dockerfile.dev` | Development container setup |
188-
| `Dockerfile.prod` | Production container setup |
189-
| `docker-compose.yml` | Multi-service container orchestration |
190-
191-
---
192-
193-
# 🔄 Local Development Workflow
194-
195-
Recommended contributor workflow:
196-
197-
1. Fork the repository
198-
2. Clone your fork locally
199-
3. Create a new branch
200-
4. Install dependencies
201-
5. Run frontend/backend locally or using Docker
202-
6. Make changes
203-
7. Test your implementation
204-
8. Commit and push changes
205-
9. Open a Pull Request
206-
207-
---
208-
209-
# 🌱 Environment Configuration
210-
211-
The project uses environment variables for configuration.
212-
213-
Frontend environment variables:
214-
215-
```env
216-
VITE_BACKEND_URL=http://localhost:5000
217-
```
218-
219-
Backend environment variables:
220-
221-
```env
222-
PORT=5000
223-
MONGO_URI=your_mongodb_connection
224-
SESSION_SECRET=your_secret
225-
```
226-
227-
Create corresponding `.env` files before running the application.
228-
229-
---
230-
231-
# 🛠️ Useful Commands
232-
233-
| Command | Description |
234-
|----------|-------------|
235-
| `npm run dev` | Start frontend locally |
236-
| `npm run build` | Create production build |
237-
| `npm run docker:dev` | Run Docker development environment |
238-
| `npm run docker:prod` | Run Docker production environment |
239-
| `npm run test` | Run frontend tests |
240-
| `npm run test:backend` | Run backend tests |
241-
242-
---
243-
24466
## 🧪 Backend Unit & Integration Testing with Jasmine
24567

24668
This project uses the Jasmine framework for backend unit and integration tests. The tests cover:
@@ -318,6 +140,3 @@ spec_files: [
318140
⬆️ Back to Top
319141
</a>
320142
</p>
321-
322-
323-

backend/.env.example

Lines changed: 0 additions & 37 deletions
This file was deleted.

backend/config/validateEnv.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

backend/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
"zod": "^4.4.3"
2626
},
2727
"devDependencies": {
28-
"jasmine": "^5.0.0",
29-
"nodemon": "^3.1.9",
30-
"supertest": "^7.0.0"
28+
"nodemon": "^3.1.9"
3129
}
3230
}

backend/server.js

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,32 @@ const bodyParser = require('body-parser');
66
require('dotenv').config();
77
const cors = require('cors');
88

9-
const { validateEnv } = require('./config/validateEnv');
10-
const logger = require('./logger');
11-
12-
// Fail fast in production when required env vars are absent.
13-
try {
14-
validateEnv();
15-
} catch (err) {
16-
logger.error(`[FATAL] ${err.message}`);
17-
process.exit(1);
18-
}
19-
209
// Passport configuration
2110
require('./config/passportConfig');
2211

23-
const app = express();
24-
25-
// In development, fall back to localhost:5173 if FRONTEND_ORIGIN is not set so
26-
// that contributors can run the stack without a full .env file.
27-
const corsOrigin = process.env.FRONTEND_ORIGIN || 'http://localhost:5173';
12+
const logger = require('./logger');
2813

29-
if (!process.env.FRONTEND_ORIGIN) {
30-
logger.warn(
31-
'FRONTEND_ORIGIN is not set; defaulting to http://localhost:5173. ' +
32-
'Set this variable in production.'
33-
);
34-
}
14+
const app = express();
3515

36-
// CORS — explicit allowlist with credentials support.
37-
// A function-based origin is required so that the header is only set (and
38-
// reflected) for allowed origins; a static string would send the header on
39-
// every response regardless of the requesting origin.
16+
// CORS configuration
17+
const allowedOrigins = ['http://localhost:5173', 'https://github-spy.etlify.app'];
4018
app.use(cors({
41-
origin: (requestOrigin, callback) => {
42-
// Allow same-origin requests (no Origin header) and the configured origin.
43-
if (!requestOrigin || requestOrigin === corsOrigin) {
44-
return callback(null, true);
45-
}
46-
callback(null, false);
47-
},
48-
credentials: true,
49-
methods: ['GET', 'POST'],
50-
allowedHeaders: ['Content-Type'],
19+
origin: function (origin, callback) {
20+
if (!origin || allowedOrigins.indexOf(origin) !== -1) {
21+
callback(null, true);
22+
} else{
23+
callback(new Error('Blocked by CORS policy'));
24+
}
25+
},
26+
credentials: true
5127
}));
5228

5329
// Middleware
5430
app.use(bodyParser.json());
5531
app.use(session({
56-
secret: process.env.SESSION_SECRET,
57-
resave: false,
58-
saveUninitialized: false,
59-
cookie: {
60-
httpOnly: true,
61-
// Only transmit the cookie over HTTPS in production.
62-
secure: process.env.NODE_ENV === 'production',
63-
sameSite: 'strict',
64-
},
32+
secret: process.env.SESSION_SECRET,
33+
resave: false,
34+
saveUninitialized: false,
6535
}));
6636
app.use(passport.initialize());
6737
app.use(passport.session());
@@ -72,10 +42,12 @@ app.use('/api/auth', authRoutes);
7242

7343
// Connect to MongoDB
7444
mongoose.connect(process.env.MONGO_URI, {}).then(() => {
75-
logger.info('Connected to MongoDB');
76-
app.listen(process.env.PORT, () => {
77-
logger.info(`Server running on port ${process.env.PORT}`);
78-
});
45+
logger.info('Connected to MongoDB');
46+
47+
const PORT = process.env.PORT || 5000;
48+
app.listen(PORT, () => {
49+
logger.info(`Server running on port ${PORT}`);
50+
});
7951
}).catch((err) => {
80-
logger.error('MongoDB connection error', err);
52+
logger.error('MongoDB connection error', err);
8153
});

index.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/crl-icon.png" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<link rel="preconnect" href="https://fonts.googleapis.com" />
8-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9-
<link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet" />
107
<title>Github Tracker</title>
118
</head>
129
<body>

0 commit comments

Comments
 (0)