mirror of
https://github.com/GithubOrgProjectPiza/server.git
synced 2026-09-05 07:36:02 +02:00
Merge branch 'main' into DB_schema
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
version: "3.4"
|
||||||
|
services:
|
||||||
|
mail:
|
||||||
|
image: boky/postfix
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- ALLOWED_SENDER_DOMAINS=mail.${DOMAIN}
|
||||||
|
ports:
|
||||||
|
- "587:587"
|
||||||
|
container_name: "postfix"
|
||||||
|
volumes:
|
||||||
|
- ./host/keys/:/etc/opendkim/keys
|
||||||
Generated
+5868
-1
File diff suppressed because it is too large
Load Diff
+13
-1
@@ -4,7 +4,9 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"start": "ts-node src/index.ts",
|
||||||
|
"debug": "nodemon src/index.ts"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -17,6 +19,16 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/GithubOrgProjectPiza/server#readme",
|
"homepage": "https://github.com/GithubOrgProjectPiza/server#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/express": "^4.17.13",
|
||||||
|
"@types/nodemailer": "^6.4.4",
|
||||||
|
"dotenv": "^16.0.0",
|
||||||
|
"express": "^4.17.3",
|
||||||
|
"nodemailer": "^6.7.2",
|
||||||
|
"ts-node": "^10.5.0",
|
||||||
"typescript": "^4.5.5"
|
"typescript": "^4.5.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^8.9.5",
|
||||||
|
"nodemon": "^1.18.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
#load .env file
|
||||||
|
|
||||||
|
[[ -f .env ]] || { echo "`tput setaf 1`✗`tput sgr0` Could not find .env file are you in the correct directory (you should be in the server directory)"; exit 1;}
|
||||||
|
|
||||||
|
set -o allexport
|
||||||
|
[[ -f .env ]] && source .env
|
||||||
|
set +o allexport
|
||||||
|
|
||||||
|
#static variables
|
||||||
|
NC='tput sgr0' #No Color
|
||||||
|
GREEN='tput setaf 2'
|
||||||
|
RED='tput setaf 1'
|
||||||
|
|
||||||
|
|
||||||
|
#check dependencies
|
||||||
|
command -v opendkim-genkey >/dev/null 2>&1 || { echo >&2 "`$RED`✗`$NC` Opendkim not installed install with your favorite package manager (opendkim-tools | opendkim-utils)"; exit 1;}
|
||||||
|
|
||||||
|
#generate dkim keys
|
||||||
|
mkdir -p ./host/keys
|
||||||
|
echo "`$GREEN`✓`$NC` Created folder"
|
||||||
|
|
||||||
|
cd ./host/keys
|
||||||
|
opendkim-genkey -b 2048 -h rsa-sha256 -r -v --subdomains -s mail -d mail.$DOMAIN
|
||||||
|
sed -i 's/h=rsa-sha256/sha256/' mail.txt
|
||||||
|
mv mail.private mail.$DOMAIN.private
|
||||||
|
mv mail.txt mail.$DOMAIN.txt
|
||||||
|
|
||||||
|
echo "`$GREEN`✓`$NC` Generated dkim keys"
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import express from "express";
|
||||||
|
import dotenv from "dotenv";
|
||||||
|
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
app.get("/", (req, res) => {
|
||||||
|
res.send("Hello World!");
|
||||||
|
});
|
||||||
|
|
||||||
|
app.listen(3000, () => {
|
||||||
|
console.log("Server is running on port 3000");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import nodemailer from "nodemailer";
|
||||||
|
import SMTPTransport from "nodemailer/lib/smtp-transport";
|
||||||
|
|
||||||
|
let mailAccount = { user: process.env.MAILUSER + "@mail." + process.env.DOMAIN, pass: process.env.MAILPASSWORD };
|
||||||
|
|
||||||
|
let transporter = nodemailer.createTransport(
|
||||||
|
new SMTPTransport({
|
||||||
|
host: "localhost",
|
||||||
|
port: 587,
|
||||||
|
secure: false,
|
||||||
|
auth: {
|
||||||
|
user: mailAccount.user,
|
||||||
|
pass: mailAccount.pass,
|
||||||
|
},
|
||||||
|
tls: {
|
||||||
|
rejectUnauthorized: false,
|
||||||
|
secureProtocol: "TLSv1_method",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
if (process.env.DEV == "true") {
|
||||||
|
console.log("test");
|
||||||
|
(async () => {
|
||||||
|
mailAccount = await nodemailer.createTestAccount();
|
||||||
|
console.log(mailAccount);
|
||||||
|
transporter = nodemailer.createTransport({
|
||||||
|
host: "smtp.ethereal.email",
|
||||||
|
port: 587,
|
||||||
|
secure: false, // true for 465, false for other ports
|
||||||
|
auth: {
|
||||||
|
user: mailAccount.user, // generated ethereal user
|
||||||
|
pass: mailAccount.pass, // generated ethereal password
|
||||||
|
},
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
const sendMail = async (from: string, to: string, subject: string, text?: string, html?: string) => {
|
||||||
|
return await transporter.sendMail({
|
||||||
|
from: from,
|
||||||
|
to: to,
|
||||||
|
subject: subject,
|
||||||
|
text: text,
|
||||||
|
html: html,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default { sendMail, mailAccount };
|
||||||
Reference in New Issue
Block a user