Skip to content

Commit 2ca2f99

Browse files
authored
TLS Config fix (#4)
1 parent f0269a9 commit 2ca2f99

15 files changed

Lines changed: 577 additions & 450 deletions

File tree

apps/backend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
},
1515
"exports": {
1616
".": "./src/index.ts",
17-
"./data": "./src/data.ts",
1817
"./shared": "./src/shared.ts"
1918
},
2019
"prisma": {

apps/backend/src/data.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/backend/src/lib/Mailer.ts

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import SMTPTransport from "nodemailer/lib/smtp-transport"
12
import { SmtpSettings } from "../../prisma/client"
23
import nodemailer from "nodemailer"
34

@@ -32,38 +33,47 @@ interface SendEmailResponse {
3233
messageId?: string
3334
}
3435

36+
type TransportOptions = SMTPTransport | SMTPTransport.Options | string
37+
3538
export class Mailer {
3639
private transporter: nodemailer.Transporter
3740

3841
constructor(smtpSettings: SmtpSettings) {
39-
const startTls = {
40-
port: 587,
41-
secure: false,
42-
requireTLS: true,
43-
}
44-
45-
const sslTls = {
46-
port: 465,
47-
secure: true,
48-
}
49-
50-
const tlsOpts =
51-
smtpSettings.encryption === "STARTTLS"
52-
? startTls
53-
: smtpSettings.encryption === "SSL_TLS"
54-
? sslTls
55-
: { port: smtpSettings.port }
56-
57-
this.transporter = nodemailer.createTransport({
58-
connectionTimeout: smtpSettings.timeout,
42+
let transportOptions: TransportOptions = {
5943
host: smtpSettings.host,
44+
port: smtpSettings.port,
45+
connectionTimeout: smtpSettings.timeout,
6046
auth: {
6147
user: smtpSettings.username,
6248
pass: smtpSettings.password,
6349
},
64-
requireTLS: smtpSettings.secure,
65-
...tlsOpts,
66-
})
50+
}
51+
52+
if (smtpSettings.encryption === "STARTTLS") {
53+
transportOptions = {
54+
...transportOptions,
55+
port: smtpSettings.port || 587, // Default STARTTLS port
56+
secure: false, // Use STARTTLS
57+
requireTLS: true, // Require STARTTLS upgrade
58+
}
59+
} else if (smtpSettings.encryption === "SSL_TLS") {
60+
transportOptions = {
61+
...transportOptions,
62+
port: smtpSettings.port || 465, // Default SSL/TLS port
63+
secure: true, // Use direct TLS connection
64+
}
65+
} else {
66+
// NONE encryption
67+
transportOptions = {
68+
...transportOptions,
69+
port: smtpSettings.port || 25, // Default non-encrypted port
70+
secure: false,
71+
requireTLS: false, // Explicitly disable TLS requirement
72+
ignoreTLS: true, // Optionally ignore TLS advertised by server if needed
73+
}
74+
}
75+
76+
this.transporter = nodemailer.createTransport(transportOptions)
6777
}
6878

6979
async sendEmail(options: SendMailOptions): Promise<SendEmailResponse> {

apps/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"@repo/shared": "workspace:*",
1213
"next": "15.1.7",
1314
"nextra": "^4.2.11",
1415
"nextra-theme-docs": "^4.2.11",

apps/docs/src/app/getting-started/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ We've made LetterSpace for simplicity and ease of use. The easiest way to get st
2929
- app_network
3030

3131
backend:
32-
image: ghcr.io/dcodesdev/letterspace:0.2.1-beta
32+
image: ghcr.io/dcodesdev/letterspace:0.2.4-beta
3333
restart: always
3434
depends_on:
3535
- db

apps/landing-page/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@repo/ui": "workspace:*",
13+
"@repo/shared": "workspace:*",
1314
"lucide-react": "^0.474.0",
1415
"next": "15.3.1",
1516
"react": "^19.0.0",

apps/landing-page/src/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { APP_VERSION } from "@repo/shared"
2+
13
export const constants = {
24
env: {
35
DOCS_URL: process.env.NEXT_PUBLIC_DOCS_URL!,
46
GITHUB_URL: process.env.NEXT_PUBLIC_GITHUB_URL!,
57
X_URL: "https://x.com/dcodesdev",
68
},
7-
version: "v0.1.0",
9+
version: APP_VERSION,
810
}
911

1012
Object.entries(constants.env).forEach(([key, value]) => {

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"dependencies": {
1414
"@hookform/resolvers": "^5.0.1",
1515
"@repo/ui": "workspace:*",
16+
"@repo/shared": "workspace:*",
1617
"@tabler/icons-react": "^3.31.0",
1718
"@tanstack/react-query": "^5.75.2",
1819
"@tanstack/react-table": "^8.21.3",

apps/web/src/pages/dashboard/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
import { useSession } from "@/hooks"
3030
import { useLocation } from "react-router"
3131
import { ThemeToggle, WithTooltip } from "@/components"
32-
import { VERSION } from "backend/data"
32+
import { APP_VERSION } from "@repo/shared"
3333

3434
const sidebarItems = [
3535
{
@@ -197,7 +197,7 @@ export function DashboardLayout() {
197197
<div className="flex items-center justify-between gap-2 px-2">
198198
<WithTooltip content="Current version">
199199
<span className="text-xs text-muted-foreground hover:text-foreground transition-colors">
200-
v{VERSION}
200+
v{APP_VERSION}
201201
</span>
202202
</WithTooltip>
203203
</div>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"version": "0.2.4-beta",
23
"name": "letterspace",
34
"private": true,
45
"scripts": {

0 commit comments

Comments
 (0)