Skip to content

Commit 49fd6f3

Browse files
feat: implement Evodron Referral Program (backend, frontend, tests)
Co-authored-by: julesdemangeot-ship-it <307666271+julesdemangeot-ship-it@users.noreply.github.com>
1 parent ef627e1 commit 49fd6f3

22 files changed

Lines changed: 6978 additions & 0 deletions

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
evodron.db
3+
*.db
4+
.env

‎app.js‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
const express = require('express');
4+
const cookieParser = require('cookie-parser');
5+
const path = require('path');
6+
7+
const authRoutes = require('./src/routes/auth');
8+
const referralRoutes = require('./src/routes/referral');
9+
10+
const app = express();
11+
const PORT = process.env.PORT || 3000;
12+
13+
// Middleware
14+
app.use(express.json());
15+
app.use(express.urlencoded({ extended: false }));
16+
app.use(cookieParser());
17+
18+
// Serve static frontend files
19+
app.use(express.static(path.join(__dirname, 'public')));
20+
21+
// API routes
22+
app.use('/api/auth', authRoutes);
23+
app.use('/api/referral', referralRoutes);
24+
25+
// Catch-all: serve index.html for client-side navigation
26+
app.get('*', (req, res) => {
27+
res.sendFile(path.join(__dirname, 'public', 'index.html'));
28+
});
29+
30+
// Only start listening when run directly (not during tests)
31+
if (require.main === module) {
32+
if (!process.env.JWT_SECRET) {
33+
console.error('ERROR: JWT_SECRET environment variable is not set. Refusing to start.');
34+
process.exit(1);
35+
}
36+
app.listen(PORT, () => {
37+
console.log(`Evodron Referral server running on http://localhost:${PORT}`);
38+
});
39+
}
40+
41+
module.exports = app;

0 commit comments

Comments
 (0)