mailer-advance 5.0.0 โ 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ๐ mailer-advance
|
|
1
|
+
# ๐ mailer-advance v6.0
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/mailer-advance)
|
|
4
4
|
[](https://www.npmjs.com/package/mailer-advance)
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
## โจ
|
|
11
|
+
## โจ v6.0 Highlights
|
|
12
12
|
|
|
13
|
-
- โก **Smart Connection**:
|
|
14
|
-
-
|
|
15
|
-
-
|
|
13
|
+
- โก **Smart Connection**: `connect()` automatically falls back to `process.env.DB_URI`.
|
|
14
|
+
- ๐ **Interactive Swagger UI**: Explore and test all APIs at `/api-docs`.
|
|
15
|
+
- ๐๏ธ **Multi-DB Persistence**: Support for MongoDB, Postgres, and MySQL.
|
|
16
|
+
- ๐ **Hot-Swapping**: Switch SMTP credentials at runtime via the Dashboard.
|
|
16
17
|
- ๐ก๏ธ **Production Ready**: Full STARTTLS support and descriptive error guards.
|
|
17
|
-
- ๐ **Swagger UI**: API docs auto-served at `/api-docs`.
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -42,18 +42,34 @@ app.use(express.json());
|
|
|
42
42
|
|
|
43
43
|
// 1. Initialize Persistence (Smart Fallback to process.env.DB_URI)
|
|
44
44
|
const repository = DatabaseFactory.createRepository(process.env.DB_TYPE || 'mongodb');
|
|
45
|
-
await repository.connect();
|
|
45
|
+
await repository.connect();
|
|
46
46
|
dbService.setRepository(repository);
|
|
47
47
|
|
|
48
48
|
// 2. Mount API Routes
|
|
49
49
|
app.use('/api/mail', contactRoutes);
|
|
50
50
|
app.use('/api/config', configRoutes);
|
|
51
51
|
|
|
52
|
-
app.listen(3000, () =>
|
|
52
|
+
app.listen(3000, () => {
|
|
53
|
+
console.log('๐ Engine active at http://localhost:3000');
|
|
54
|
+
console.log('๐ API Docs: http://localhost:3000/api-docs');
|
|
55
|
+
});
|
|
53
56
|
```
|
|
54
57
|
|
|
55
58
|
---
|
|
56
59
|
|
|
60
|
+
## ๐ Interactive API Documentation (Swagger)
|
|
61
|
+
|
|
62
|
+
V6.0.0 introduces a fully integrated **Swagger UI** for easier development and testing. Once your server is running, navigate to:
|
|
63
|
+
|
|
64
|
+
๐ **`http://localhost:3000/api-docs`**
|
|
65
|
+
|
|
66
|
+
From there, you can:
|
|
67
|
+
- ๐ **Explore**: See all available endpoints and their data structures.
|
|
68
|
+
- ๐งช **Test**: Send live requests to your mailer engine directly from the browser.
|
|
69
|
+
- ๐ **Spec**: Download the OpenApi spec for use in other tools.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
57
73
|
## โ๏ธ Environment Configuration (.env)
|
|
58
74
|
|
|
59
75
|
| Variable | Requirement | Description |
|
|
@@ -64,13 +80,12 @@ app.listen(3000, () => console.log('๐ Engine active at http://localhost:3000'
|
|
|
64
80
|
| `MAIL_PORT` | Optional | Default SMTP Port (Default: `587`). |
|
|
65
81
|
|
|
66
82
|
### ๐ก The .env Setup Guide
|
|
67
|
-
For the engine to function correctly as a library, ensure your project's `.env` contains:
|
|
68
83
|
```env
|
|
69
84
|
# Database
|
|
70
85
|
DB_TYPE=mongodb
|
|
71
86
|
DB_URI=mongodb://127.0.0.1:27017/my_mailer_db
|
|
72
87
|
|
|
73
|
-
# Fallback SMTP
|
|
88
|
+
# Fallback SMTP
|
|
74
89
|
MAIL_HOST=smtp.your-provider.com
|
|
75
90
|
MAIL_PORT=587
|
|
76
91
|
MAIL_USER=admin@example.com
|
|
@@ -81,19 +96,9 @@ MAIL_PASS=your-secure-password
|
|
|
81
96
|
|
|
82
97
|
## ๐ Security & Best Practices
|
|
83
98
|
|
|
84
|
-
- **App Privacy**: Always wrap the mailer routes/UI with your own authentication middleware
|
|
85
|
-
- **TLS validation**: Ensure `rejectUnauthorized` is `true` for production SMTP
|
|
86
|
-
- **Secrets**: Encrypt your `.env` files using
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## ๐ Troubleshooting
|
|
91
|
-
|
|
92
|
-
### `Error: Database connection URI is required`
|
|
93
|
-
This occurs if `process.env.DB_URI` is undefined.
|
|
94
|
-
1. Ensure your `.env` file exists in the root of your project.
|
|
95
|
-
2. Verify you are using `dotenv.config()` BEFORE initializing the mailer.
|
|
96
|
-
3. Check the variable name is exactly `DB_URI`.
|
|
99
|
+
- **App Privacy**: Always wrap the mailer routes/UI with your own authentication middleware.
|
|
100
|
+
- **TLS validation**: Ensure `rejectUnauthorized` is `true` for production SMTP.
|
|
101
|
+
- **Secrets**: Encrypt your `.env` files using [Dotenvx](https://dotenvx.com).
|
|
97
102
|
|
|
98
103
|
---
|
|
99
104
|
|
package/package.json
CHANGED