add nodejs server, register page
This commit is contained in:
parent
8d141630f2
commit
414082e395
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
# public directory
|
||||
public/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
docker-compose.yml
|
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM node:18
|
||||
WORKDIR /usr/src/app
|
||||
COPY package*.json ./
|
||||
RUN npm install --only=production
|
||||
COPY . .
|
||||
EXPOSE 3000
|
||||
CMD ["node", "app.js"]
|
62
app.js
Normal file
62
app.js
Normal file
@ -0,0 +1,62 @@
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const path = require('path');
|
||||
const winston = require('winston');
|
||||
const rateLimit = require('express-rate-limit');
|
||||
|
||||
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' })
|
||||
],
|
||||
});
|
||||
|
||||
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,
|
||||
});
|
||||
|
||||
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) => {
|
||||
res.render('index');
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
|
||||
app.get('/register', (req, res) => {
|
||||
res.render('register');
|
||||
});
|
||||
|
||||
app.get('/services', (req, res) => {
|
||||
res.render('services');
|
||||
});
|
||||
|
||||
const PORT = process.env.PORT || 3000;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on port ${PORT}`);
|
||||
});
|
@ -1,5 +0,0 @@
|
||||
server {
|
||||
location / {
|
||||
root /data/www;
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
services:
|
||||
mail:
|
||||
image: nginx
|
||||
pontus-mail:
|
||||
build: .
|
||||
container_name: pontus-mail
|
||||
restart: always
|
||||
ports:
|
||||
- 2380:80
|
||||
- "80:3000"
|
||||
volumes:
|
||||
- /path/to/root/default.conf:/etc/nginx/conf.d/default.conf
|
||||
- /path/to/root/public:/data/www/
|
||||
- ./register.log:/usr/src/app/register.log
|
||||
environment:
|
||||
- NODE_ENV=production
|
19
package.json
Normal file
19
package.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "pontus-mail",
|
||||
"version": "1.0.0",
|
||||
"description": "Landing page for p0ntus mail",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.3",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^4.21.1",
|
||||
"express-rate-limit": "^7.4.1",
|
||||
"winston": "^3.17.0"
|
||||
}
|
||||
}
|
9
public/js/checkUsernameInput.js
Normal file
9
public/js/checkUsernameInput.js
Normal file
@ -0,0 +1,9 @@
|
||||
document.getElementById('email').addEventListener('input', function() {
|
||||
let emailInput = document.getElementById('email').value;
|
||||
let prefix = document.getElementById('email-prefix');
|
||||
if (emailInput.includes('@p0ntus.com')) {
|
||||
prefix.innerText = emailInput.split('@')[0];
|
||||
} else {
|
||||
prefix.innerText = emailInput;
|
||||
}
|
||||
});
|
6
register.log
Normal file
6
register.log
Normal file
@ -0,0 +1,6 @@
|
||||
{"formData":{"email":"iurfhiu","message":"fwiuhef","name":"uifrhifh","telegram":"fiuwhwiu"},"level":"info","message":"New registration","timestamp":"2024-12-03T23:20:47.428Z"}
|
||||
2024-12-03T23:23:44.763Z [INFO] New registration:
|
||||
Name: refefrfre
|
||||
Email: frferefr
|
||||
Message: ffferfrefe
|
||||
Telegram: erffreefr
|
57
self
57
self
@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
SC_VERSION=1.0.0
|
||||
SC_CODENAME="wormhole"
|
||||
COLOR_RESET="\033[0m"
|
||||
COLOR_GREEN="\033[1;32m"
|
||||
COLOR_RED="\033[1;31m"
|
||||
COLOR_YELLOW="\033[1;33m"
|
||||
COLOR_BLUE="\033[1;34m"
|
||||
COLOR_CYAN="\033[1;36m"
|
||||
|
||||
function start() {
|
||||
if [ ! -d "src" ]; then
|
||||
echo -e "${COLOR_RED}src directory not found, cannot continue${COLOR_RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p public
|
||||
|
||||
cp -r src/* public/
|
||||
echo -e "${COLOR_GREEN}Created public dir and copied files successfully${COLOR_RESET}"
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if [ -d "public" ]; then
|
||||
rm -rf public
|
||||
echo -e "${COLOR_GREEN}Deleted public directory${COLOR_RESET}"
|
||||
else
|
||||
echo -e "${COLOR_RED}No public directory to delete${COLOR_RESET}"
|
||||
fi
|
||||
}
|
||||
|
||||
function help() {
|
||||
echo -e "${COLOR_GREEN}self version:${COLOR_RESET} ${COLOR_BLUE}${SC_VERSION} ${SC_CODENAME}${COLOR_RESET}"
|
||||
echo -e "${COLOR_BLUE}Usage:${COLOR_RESET} ./self [command]\n"
|
||||
echo -e "${COLOR_YELLOW}Commands:${COLOR_RESET}"
|
||||
echo -e " ${COLOR_CYAN}help${COLOR_RESET} Shows this help message."
|
||||
echo -e " ${COLOR_CYAN}start${COLOR_RESET} Copies files to public directory."
|
||||
echo -e " ${COLOR_CYAN}stop${COLOR_RESET} Removes public directory."
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
help)
|
||||
help
|
||||
;;
|
||||
*)
|
||||
echo -e "${COLOR_RED}Invalid command: $1\n${COLOR_RESET}"
|
||||
help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
@ -15,16 +15,15 @@
|
||||
<div class="container">
|
||||
<h1><i class="fa-solid fa-envelope text-dark ico"></i> p0ntus mail.</h1>
|
||||
<h3>simple, mindful, secure email.</h3>
|
||||
<!-- Simple link menu for Home (bolded) and Services, centered -->
|
||||
<nav class="nav justify-content-center">
|
||||
<a href="#" class="nav-link text-dark"><b>Home</b></a>
|
||||
<a href="/services.html" class="nav-link text-dark">Services</a>
|
||||
<a href="/services" class="nav-link text-dark">Services</a>
|
||||
</nav>
|
||||
<i class="il mt-5">Where can I direct your request?</i>
|
||||
<hr>
|
||||
<div class="text-start">
|
||||
<p class="il"><i>If you aren't a current user</i></p>
|
||||
<a href="/register.html" class="btn bg-dark text-white"><i class="fa-solid fa-user-plus ico-sm"></i> Register</a>
|
||||
<a href="/register" class="btn bg-dark text-white"><i class="fa-solid fa-user-plus ico-sm"></i> Register</a>
|
||||
<hr>
|
||||
<p class="il"><i>If you are a current user</i></p>
|
||||
<a href="/SOGo" class="btn bg-dark text-white"><i class="fa-solid fa-envelope ico-sm"></i> Webmail</a>
|
43
src/register.ejs
Normal file
43
src/register.ejs
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Register - p0ntus mail</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Register</h1>
|
||||
<h3>Registration is done via email</h3>
|
||||
<i>Fill out the form and send your email to receive your credentials.</i>
|
||||
<hr>
|
||||
<form id="registration-form" method="POST" action="/register">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Name that goes in email header (full name/username/alias):</label>
|
||||
<input type="text" class="form-control" id="name" name="name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">I would like this email:</label>
|
||||
<input type="text" class="form-control" id="email" name="email" required>
|
||||
<div class="form-text">Your email will be: <span id="email-prefix">name</span>@p0ntus.com</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="message" class="form-label">I want an email because:</label>
|
||||
<textarea class="form-control" id="message" name="message" rows="3" required></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="telegram" class="form-label">Telegram username:</label>
|
||||
<input type="text" class="form-control" id="telegram" name="telegram" required>
|
||||
</div>
|
||||
<button type="submit" class="btn bg-dark text-white"><i class="fa-solid fa-envelope ico-sm"></i> Send</button>
|
||||
</form>
|
||||
</div>
|
||||
<script src="/src/js/checkUsernameInput.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,28 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Register - p0ntus mail</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Register</h1>
|
||||
<h3>Registration is done on Telegram</h3>
|
||||
<i>Click the button below to register</i>
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<a href="https://t.me/ihatearchbtw42" class="btn btn-primary">
|
||||
<img src="https://telegram.org/img/t_logo.png" alt="Telegram" style="width: 20px; height: 20px; margin-right: 10px;">
|
||||
Register on Telegram
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user