Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ sudo apt-get install node npm
npm install
```

You'll also need to install and run the Typescript compiler inside the server folder:
```sh
sudo npm install -g typescript
tsc
```

The most complex part is doing setup for HTTPS (optional):
- You must have a certificate, you can get one for free from [Let's Encrypt](https://letsencrypt.org)
- You will need to create a directory called `cert` that will contain:
Expand Down
44 changes: 23 additions & 21 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@ import util from "util";
import nodemailer from "nodemailer";
import JSONTransport from "nodemailer/lib/json-transport/index.js";

const smtpPassword = fs.readFileSync("conf/smtp_password.txt", { "encoding": "utf-8" });
let transport = nodemailer.createTransport({
host: "smtp.ionos.com",
port: 587,
//secure: true,
auth: {
user: "no-reply@blocksverse.com",
pass: smtpPassword,
}
});

// verify connection configuration
transport.verify(function (error) {
if (error) {
console.log(error);
} else {
console.log("SMTP backend is ready");
}
});
const smtpPassword = fs.existsSync("conf/smtp_password.txt") ? fs.readFileSync("conf/smtp_password.txt", { "encoding": "utf-8" }) : false;
if(smtpPassword) {
var transport = nodemailer.createTransport({
host: "smtp.ionos.com",
port: 587,
//secure: true,
auth: {
user: "no-reply@blocksverse.com",
pass: smtpPassword,
}
});

// verify connection configuration
transport.verify(function (error) {
if (error) {
console.log(error);
} else {
console.log("SMTP backend is ready");
}
});
}

// Init logging
const logFilePath = "latest.log";
Expand Down Expand Up @@ -153,7 +155,7 @@ process.on('SIGTERM', () => {
});
});

if (process.env.NODE_ENV === "production" || true) {
if ((process.env.NODE_ENV === "production" || true) && smtpPassword) {
process.on("uncaughtException", (err) => {
if (err === "exiting") return;
if (err.stack) console.error(err.stack);
Expand All @@ -170,4 +172,4 @@ if (process.env.NODE_ENV === "production" || true) {
}

console.log("The server is ready!");
console.log("Note: If you want the server to be publicly accessible (outside your house), be sure to port-forward port 8080 (there are many tutorials on internet)")
console.log("Note: If you want the server to be publicly accessible (outside your house), be sure to port-forward port 8080 (there are many tutorials on internet)")