From 9bf1532e344cf76c910ddaca0d57a1d5e31e040f Mon Sep 17 00:00:00 2001 From: Aidan Date: Thu, 23 Jan 2025 16:26:04 -0500 Subject: [PATCH] update services information, .env verification, update privacy policy, add git to home links, linting and minor rewording in readme, update guides styling --- README.md | 42 ++++++++++++++++++++++++++++------- app.js | 57 +++++++++++++++--------------------------------- src/guides.ejs | 4 ++-- src/index.ejs | 1 + src/privacy.ejs | 18 ++++++++------- src/services.ejs | 14 +++++++----- 6 files changed, 73 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index d991595..c08b03c 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,95 @@ # pontus-mail -[![Last Update](https://img.shields.io/badge/last_update-31_Dec_2024-blue)](#) + +[![Last Update](https://img.shields.io/badge/last_update-23_Jan_2025-blue)](https://github.com/ihatenodejs/pontus-mail) [![License: CC0-1.0](https://img.shields.io/badge/License-CC0_1.0-lightgrey.svg)](http://creativecommons.org/publicdomain/zero/1.0/) Landing page for p0ntus mail -# Self hosting -## Traditional Node.js + +## Self hosting + +### Using Express + 1. Clone the repo + ```bash git clone https://github.com/ihatenodejs/pontus-mail.git cd pontus-mail ``` + 2. Copy the example `docker-compose.yml` + ```bash mv docker-compose.yml.example docker-compose.yml ``` + 3. Copy the example `donations.json` + ```bash mv donations.json.example donations.json ``` + 4. Copy the example `.env` + ```bash mv .env.example .env ``` - Make sure you edit this with your MySQL server information and other values. + Make sure you edit this with the desired internal port. We suggest keeping the internal port set to `3000`. 5. Install dependencies + ```bash npm install ``` + 6. Start the server + ```bash node app.js ``` You will now have a fully functioning Node.js Express server, which will be running on port `3000`. -## With Docker + +### Using Docker + You can also use Docker to self-host pontus-mail's frontend. Make sure you have docker-compose or docker-compose-plugin installed on your system. + 1. Clone the repo + ```bash git clone https://github.com/ihatenodejs/pontus-mail.git cd pontus-mail ``` + 2. Copy the example `docker-compose.yml` + ```bash mv docker-compose.yml.example docker-compose.yml ``` + 3. Copy the example `.env` + ```bash mv .env.example .env ``` - Make sure you edit this file with values matching in `docker-compose.xml`, and other desired values like admin username/password. + This configuration's defaults have been set to be compatible with Docker. Please do not change this file unless you know what you're doing! 4. Copy the example `donations.json` + ```bash mv donations.json.example donations.json ``` + 5. Start and build Docker containers + ```bash docker compose up -d --build ``` You will now have a fully functioning Node.js Express server, which will be running on the port specified in `docker-compose.yml`, and internally on port `3000`. -# To-Do +## To-Do + - [ ] Port to NextJS? - [ ] Hovering effects for buttons +- [ ] Reintegrate backend logic for counters on home page - [ ] Statistics animation - diff --git a/app.js b/app.js index ca5c6c9..34ece15 100644 --- a/app.js +++ b/app.js @@ -6,6 +6,21 @@ const axios = require('axios'); const NodeCache = require('node-cache'); const cache = new NodeCache({ stdTTL: 1800 }); +function checkSetup() { + if (!fs.existsSync(path.join(__dirname, '.env'))) { + console.error("Couldn't find .env file, please create one using the provided .env.example file."); + process.exit(1); + } + + const reqVar = ['INTERNAL_PORT']; + const missingVar = reqVar.filter(envVar => !process.env[envVar]); + + if (missingVar.length > 0) { + console.error(`Oops, you're missing these required variables in your .env file: ${missingVar.join(', ')}`); + process.exit(1); + } +} + require('dotenv').config(); const app = express(); @@ -15,45 +30,8 @@ app.set('views', path.join(__dirname, 'src')); app.use(bodyParser.urlencoded({ extended: false })); app.use(express.static(path.join(__dirname, 'public'))); -//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 []; -// } -//} - +// TODO: Reintegrate backend logic for counters on home page app.get('/', async (req, res) => { - //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; - res.render('index', { currentPage: 'home' }); }); @@ -122,7 +100,8 @@ app.get('/guides/vaultwarden/firefox', (req, res) => { res.render('guides/vaultwarden/firefox', { currentPage: 'guides' }); }); -// Start server on internal port defined in .env +// Verify .env and start server on internal port defined in .env +checkSetup(); app.listen(process.env.INTERNAL_PORT, () => { console.log(`Server started on port ${process.env.INTERNAL_PORT}`); }); \ No newline at end of file diff --git a/src/guides.ejs b/src/guides.ejs index 1163117..b68f868 100644 --- a/src/guides.ejs +++ b/src/guides.ejs @@ -16,7 +16,7 @@ - Email + Email
- User Dashboard + User Dashboard

You may request for additional storage, or increased account limits by contacting adminp0ntus.com. We operate under a "fair use" policy.

You may also be limited in storage depending on your use. There is a 100% chance you will get 4000 MB if you would like to actually use the email service. Some people will not use their accounts and hold up disk quotas.

+

All aforementioned services are self-hosted on our servers. All data is under control by me and the hosting provider (Namecheap).

Vaultwarden

Vaultwarden is a password manager that is included with your services. You can access it by visiting vaultwarden.p0ntus.com and creating a account.

-

You do not need a p0ntus mail account to create a Vaultwarden account.

+

You will need a p0ntus mail account to create a Vaultwarden account.

<%- include('shards/footer') %> \ No newline at end of file