2024-12-03 22:36:16 -05:00
|
|
|
const express = require('express');
|
|
|
|
const bodyParser = require('body-parser');
|
|
|
|
const path = require('path');
|
2024-12-04 20:34:11 -05:00
|
|
|
const fs = require('fs');
|
2024-12-04 13:11:08 -05:00
|
|
|
//const winston = require('winston');
|
|
|
|
//const rateLimit = require('express-rate-limit');
|
2024-12-03 22:36:16 -05:00
|
|
|
|
2024-12-04 13:11:08 -05:00
|
|
|
//const logger = winston.createLogger({
|
|
|
|
// level: 'info',
|
|
|
|
// format: winston.format.combine(
|
|
|
|
// winston.format.timestamp(),
|
|
|
|
// winston.format.printf(({ timestamp, level, message }) => {
|
|
|
|
// return `${timestamp} [${level.toUpperCase()}] ${message}`;
|
|
|
|
// })
|
|
|
|
// ),
|
|
|
|
// transports: [
|
|
|
|
// new winston.transports.File({ filename: 'register.log' })
|
|
|
|
// ],
|
|
|
|
//});
|
2024-12-03 22:53:10 -05:00
|
|
|
|
2024-12-04 13:11:08 -05:00
|
|
|
//const exclusions = JSON.parse(fs.readFileSync('exclusions.json', 'utf8')).excludedIPs;
|
|
|
|
//const registerLimiter = rateLimit({
|
|
|
|
// windowMs: 24 * 60 * 60 * 1000,
|
|
|
|
// max: 1,
|
|
|
|
// message: 'You have already submitted a registration today. Please try again tomorrow.',
|
|
|
|
// standardHeaders: true,
|
|
|
|
// legacyHeaders: false,
|
|
|
|
// skip: (req, res) => exclusions.includes(req.ip)
|
|
|
|
//});
|
2024-12-03 22:36:16 -05:00
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
|
|
|
app.set('view engine', 'ejs');
|
|
|
|
app.set('views', path.join(__dirname, 'src'));
|
|
|
|
|
|
|
|
app.use(bodyParser.urlencoded({ extended: false }));
|
|
|
|
|
|
|
|
app.use(express.static(path.join(__dirname, 'public')));
|
|
|
|
|
|
|
|
app.get('/', (req, res) => {
|
2024-12-04 20:34:11 -05:00
|
|
|
res.render('index', { currentPage: 'home' });
|
2024-12-03 22:36:16 -05:00
|
|
|
});
|
|
|
|
|
2024-12-04 13:11:08 -05:00
|
|
|
//app.post('/register', registerLimiter, (req, res) => {
|
|
|
|
// const formData = req.body;
|
|
|
|
// logger.info(`New registration:
|
|
|
|
// Name: ${formData.name}
|
|
|
|
// Email: ${formData.email}
|
|
|
|
// Reason: ${formData.message}
|
|
|
|
// Telegram: ${formData.telegram}`);
|
|
|
|
// res.render('success');
|
|
|
|
//});
|
2024-12-03 22:36:16 -05:00
|
|
|
|
2024-12-04 13:11:08 -05:00
|
|
|
// Shelved for now
|
|
|
|
// Logic needs improvements
|
|
|
|
|
|
|
|
//app.get('/success', (req, res) => {
|
|
|
|
// res.render('success');
|
|
|
|
//});
|
2024-12-03 23:08:06 -05:00
|
|
|
|
2024-12-04 20:34:11 -05:00
|
|
|
app.get('/services', (req, res) => {
|
|
|
|
res.render('services', { currentPage: 'services' });
|
|
|
|
});
|
|
|
|
|
2024-12-03 22:36:16 -05:00
|
|
|
app.get('/register', (req, res) => {
|
2024-12-04 20:34:11 -05:00
|
|
|
res.render('register', { currentPage: 'register' });
|
2024-12-03 22:36:16 -05:00
|
|
|
});
|
|
|
|
|
2024-12-04 20:34:11 -05:00
|
|
|
app.get('/donate', (req, res) => {
|
|
|
|
const donations = JSON.parse(fs.readFileSync('donations.json', 'utf8'));
|
|
|
|
res.render('donate', {
|
|
|
|
currentPage: 'donate',
|
|
|
|
bitcoin: donations.bitcoin,
|
|
|
|
litecoin: donations.litecoin,
|
|
|
|
ethereum: donations.ethereum,
|
|
|
|
current: donations.current,
|
|
|
|
goal: donations.goal
|
|
|
|
});
|
2024-12-03 22:36:16 -05:00
|
|
|
});
|
|
|
|
|
2024-12-05 10:11:58 -05:00
|
|
|
app.get('/privacy', (req, res) => {
|
|
|
|
res.render('privacy', { currentPage: 'privacy' });
|
|
|
|
});
|
|
|
|
|
2024-12-03 22:36:16 -05:00
|
|
|
const PORT = process.env.PORT || 3000;
|
|
|
|
app.listen(PORT, () => {
|
|
|
|
console.log(`Server is running on port ${PORT}`);
|
|
|
|
});
|