2024-12-03 22:36:16 -05:00
|
|
|
const express = require('express');
|
|
|
|
const bodyParser = require('body-parser');
|
|
|
|
const path = require('path');
|
2024-12-20 00:31:24 -05:00
|
|
|
const fs = require('fs');
|
2024-12-31 20:11:41 -05:00
|
|
|
const axios = require('axios');
|
|
|
|
const NodeCache = require('node-cache');
|
|
|
|
const cache = new NodeCache({ stdTTL: 1800 });
|
2024-12-03 22:36:16 -05:00
|
|
|
|
2024-12-14 12:35:18 -05:00
|
|
|
require('dotenv').config();
|
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')));
|
2024-12-14 12:35:18 -05:00
|
|
|
|
2025-01-19 18:27:23 -05:00
|
|
|
//async function fetchDomainData() {
|
|
|
|
// const cachedData = cache.get('domainData');
|
|
|
|
// if (cachedData) {
|
|
|
|
// return cachedData;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// try {
|
|
|
|
// const response = await axios.get('https://user.p0ntus.com/api/v1/get/domain/all', {
|
|
|
|
// headers: {
|
|
|
|
// 'accept': 'application/json',
|
|
|
|
// 'X-API-Key': process.env.MC_API_KEY
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// const domainData = response.data;
|
|
|
|
// cache.set('domainData', domainData);
|
|
|
|
// return domainData;
|
|
|
|
// } catch (error) {
|
|
|
|
// console.error('Error fetching domain data:', error);
|
|
|
|
// return [];
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
//function getDomains() {
|
|
|
|
// const domainsPath = path.join(__dirname, 'domains.txt');
|
|
|
|
// try {
|
|
|
|
// const domains = fs.readFileSync(domainsPath, 'utf-8').split('\n').filter(Boolean);
|
|
|
|
// return domains;
|
|
|
|
// } catch (error) {
|
|
|
|
// console.error('Error reading domains.txt:', error);
|
|
|
|
// return [];
|
|
|
|
// }
|
|
|
|
//}
|
2024-12-14 12:35:18 -05:00
|
|
|
|
2024-12-31 20:11:41 -05:00
|
|
|
app.get('/', async (req, res) => {
|
2025-01-19 18:27:23 -05:00
|
|
|
//const domainData = await fetchDomainData();
|
|
|
|
//const domainCount = Array.isArray(domainData) ? domainData.length : 0;
|
|
|
|
//const accountCount = Array.isArray(domainData) ? domainData.reduce((acc, domain) => acc + domain.mboxes_in_domain, 0) : 0;
|
|
|
|
//const totalData = Array.isArray(domainData) ? domainData.reduce((acc, domain) => acc + parseInt(domain.bytes_total), 0) / (1024 * 1024) : 0;
|
2024-12-31 20:11:41 -05:00
|
|
|
|
2025-01-19 18:27:23 -05:00
|
|
|
res.render('index', { currentPage: 'home' });
|
2024-12-03 22:36:16 -05:00
|
|
|
});
|
|
|
|
|
2024-12-04 20:34:11 -05:00
|
|
|
app.get('/services', (req, res) => {
|
|
|
|
res.render('services', { currentPage: 'services' });
|
|
|
|
});
|
|
|
|
|
|
|
|
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,
|
2024-12-20 00:48:37 -05:00
|
|
|
monero: donations.monero,
|
|
|
|
solana: donations.solana,
|
2024-12-04 20:34:11 -05:00
|
|
|
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-28 13:05:50 -06:00
|
|
|
// Guide routes
|
|
|
|
// TODO: Improve how guides are routed to be simpler
|
|
|
|
|
2024-12-08 18:14:58 -05:00
|
|
|
app.get('/guides', (req, res) => {
|
|
|
|
res.render('guides', { currentPage: 'guides' });
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get('/guides/user', (req, res) => {
|
|
|
|
res.render('guides/user/index', { currentPage: 'guides' });
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get('/guides/webmail', (req, res) => {
|
|
|
|
res.render('guides/webmail/index', { currentPage: 'guides' });
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get('/guides/vaultwarden/android', (req, res) => {
|
|
|
|
res.render('guides/vaultwarden/android', { currentPage: 'guides' });
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get('/guides/vaultwarden/chrome', (req, res) => {
|
|
|
|
res.render('guides/vaultwarden/chrome', { currentPage: 'guides' });
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get('/guides/vaultwarden/firefox', (req, res) => {
|
|
|
|
res.render('guides/vaultwarden/firefox', { currentPage: 'guides' });
|
|
|
|
});
|
|
|
|
|
2024-12-28 13:05:50 -06:00
|
|
|
// Start server on internal port defined in .env
|
|
|
|
app.listen(process.env.INTERNAL_PORT, () => {
|
|
|
|
console.log(`Server started on port ${process.env.INTERNAL_PORT}`);
|
2024-12-03 22:36:16 -05:00
|
|
|
});
|