Extract ports
This commit is contained in:
parent
32e7fa4fbd
commit
64db4b3a7b
|
@ -45,6 +45,7 @@
|
||||||
"script": "lib",
|
"script": "lib",
|
||||||
"env": {
|
"env": {
|
||||||
"NODE_ENV": "production",
|
"NODE_ENV": "production",
|
||||||
|
"WEB_PORT": "8000",
|
||||||
"EMAIL_PORT": "25"
|
"EMAIL_PORT": "25"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,6 +8,9 @@ import { promises as fs } from "fs";
|
||||||
import writeFileAtomic from "write-file-atomic";
|
import writeFileAtomic from "write-file-atomic";
|
||||||
import cryptoRandomString from "crypto-random-string";
|
import cryptoRandomString from "crypto-random-string";
|
||||||
|
|
||||||
|
export const WEB_PORT = process.env.WEB_PORT ?? 8000;
|
||||||
|
export const EMAIL_PORT = process.env.EMAIL_PORT ?? 2525;
|
||||||
|
|
||||||
export const webServer = express()
|
export const webServer = express()
|
||||||
.use(express.static("static"))
|
.use(express.static("static"))
|
||||||
.use(express.urlencoded({ extended: true }))
|
.use(express.urlencoded({ extended: true }))
|
||||||
|
@ -71,7 +74,7 @@ export const webServer = express()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.listen(process.env.WEB_PORT ?? 8000);
|
.listen(WEB_PORT);
|
||||||
|
|
||||||
export const emailServer = new SMTPServer({
|
export const emailServer = new SMTPServer({
|
||||||
disabledCommands: ["AUTH", "STARTTLS"],
|
disabledCommands: ["AUTH", "STARTTLS"],
|
||||||
|
@ -111,7 +114,7 @@ export const emailServer = new SMTPServer({
|
||||||
callback(new Error("Failed to receive message. Please try again."));
|
callback(new Error("Failed to receive message. Please try again."));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}).listen(process.env.EMAIL_PORT ?? 2525);
|
}).listen(EMAIL_PORT);
|
||||||
|
|
||||||
function Layout({ children }: { children: React.ReactNode }) {
|
function Layout({ children }: { children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { webServer, emailServer } from ".";
|
import { webServer, emailServer, WEB_PORT, EMAIL_PORT } from ".";
|
||||||
import nodemailer from "nodemailer";
|
import nodemailer from "nodemailer";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import qs from "qs";
|
import qs from "qs";
|
||||||
import { AddressInfo } from "net";
|
|
||||||
|
|
||||||
test("create feed", async () => {
|
test("create feed", async () => {
|
||||||
const identifier = await createFeed();
|
const identifier = await createFeed();
|
||||||
|
@ -154,10 +153,10 @@ afterAll(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const webClient = axios.create({
|
const webClient = axios.create({
|
||||||
baseURL: `http://localhost:${(webServer.address() as AddressInfo).port}`,
|
baseURL: `http://localhost:${WEB_PORT}`,
|
||||||
});
|
});
|
||||||
const emailClient = nodemailer.createTransport(
|
const emailClient = nodemailer.createTransport(
|
||||||
`smtp://localhost:${(emailServer.address() as AddressInfo).port}`
|
`smtp://localhost:${EMAIL_PORT}`
|
||||||
);
|
);
|
||||||
|
|
||||||
async function createFeed(): Promise<string> {
|
async function createFeed(): Promise<string> {
|
||||||
|
|
Loading…
Reference in New Issue