Skip to content

Commit a13eec2

Browse files
authored
Merge branch 'main' into feat/submit-on-submit
2 parents b5c4884 + e6ef4be commit a13eec2

File tree

4 files changed

+95
-2
lines changed

4 files changed

+95
-2
lines changed

README.md

+43
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,47 @@ Add JSDoc comments with Swagger annotations to your API routes:
225225
* 200:
226226
* description: Success response
227227
*/
228+
```
229+
230+
### Environment Variables
231+
232+
Make sure your `.env` file includes:
233+
234+
```env
235+
DATABASE_URL=postgres://postgres:postgres@localhost:5432/mint
236+
237+
# Email Configuration
238+
SMTP_HOST=smtp.example.com
239+
SMTP_PORT=587
240+
SMTP_SECURE=false
241+
242+
SMTP_PASSWORD=your-smtp-password
243+
SMTP_FROM_NAME=Mint Platform
244+
245+
```
246+
247+
#### Email Configuration Details
248+
249+
- `SMTP_HOST`: Your SMTP server hostname (e.g., smtp.gmail.com for Gmail)
250+
- `SMTP_PORT`: SMTP port (usually 587 for TLS or 465 for SSL)
251+
- `SMTP_SECURE`: Use `true` for port 465, `false` for other ports
252+
- `SMTP_USER`: Your SMTP username/email
253+
- `SMTP_PASSWORD`: Your SMTP password or app-specific password
254+
- `SMTP_FROM_NAME`: Display name for sent emails
255+
- `SMTP_FROM_EMAIL`: Email address used as sender
256+
257+
#### Gmail Setup
258+
259+
If using Gmail:
260+
1. Enable 2-factor authentication
261+
2. Generate an app password
262+
3. Use the app password as `SMTP_PASSWORD`
263+
264+
Example Gmail configuration:
265+
```env
266+
SMTP_HOST=smtp.gmail.com
267+
SMTP_PORT=587
268+
SMTP_SECURE=false
269+
270+
SMTP_PASSWORD=your-app-specific-password
228271
```

lib/email.ts

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import nodemailer from "nodemailer";
2+
3+
type EmailOptions = {
4+
to: string;
5+
subject: string;
6+
text?: string;
7+
html?: string;
8+
};
9+
10+
// Create reusable transporter
11+
const transporter = nodemailer.createTransport({
12+
host: process.env.SMTP_HOST,
13+
port: parseInt(process.env.SMTP_PORT || "587"),
14+
secure: process.env.SMTP_SECURE === "true",
15+
auth: {
16+
user: process.env.SMTP_USER,
17+
pass: process.env.SMTP_PASSWORD,
18+
},
19+
});
20+
21+
export async function sendEmail({ to, subject, text, html }: EmailOptions) {
22+
try {
23+
const info = await transporter.sendMail({
24+
from: `"${process.env.SMTP_FROM_NAME}" <${process.env.SMTP_FROM_EMAIL}>`,
25+
to,
26+
subject,
27+
text,
28+
html,
29+
});
30+
31+
console.log("Email sent:", info.messageId);
32+
return info;
33+
} catch (error) {
34+
console.error("Error sending email:", error);
35+
throw error;
36+
}
37+
}
38+
39+
// Verify SMTP connection
40+
export async function verifyEmailConfig() {
41+
try {
42+
await transporter.verify();
43+
console.log("SMTP connection verified successfully");
44+
return true;
45+
} catch (error) {
46+
console.error("SMTP verification failed:", error);
47+
return false;
48+
}
49+
}

lib/seeder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ async function createContests(
505505
endTime: contestEnd,
506506
organizerId: orgId,
507507
organizerKind: "org",
508-
allowList: [],
509-
disallowList: [],
508+
allowList: [], // Add missing required fields
509+
disallowList: [], // Add missing required fields
510510
})
511511
.returning();
512512

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"marked": "^15.0.6",
6767
"next": "14.2.13",
6868
"next-swagger-doc": "^0.4.1",
69+
"nodemailer": "^6.10.0",
6970
"oslo": "^1.2.1",
7071
"pg": "^8.13.1",
7172
"prom-client": "^15.1.0",

0 commit comments

Comments
 (0)