mailer-advance 6.0.0 → 7.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 CHANGED
@@ -1,4 +1,4 @@
1
- # 🚀 mailer-advance v6.0
1
+ # 🚀 mailer-advance v7.0
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/mailer-advance.svg?style=flat-square)](https://www.npmjs.com/package/mailer-advance)
4
4
  [![license](https://img.shields.io/npm/l/mailer-advance.svg?style=flat-square)](https://www.npmjs.com/package/mailer-advance)
@@ -8,10 +8,10 @@
8
8
 
9
9
  ---
10
10
 
11
- ## ✨ v6.0 Highlights
11
+ ## ✨ v7.0 Highlights
12
12
 
13
13
  - ⚡ **Smart Connection**: `connect()` automatically falls back to `process.env.DB_URI`.
14
- - 📖 **Interactive Swagger UI**: Explore and test all APIs at `/api-docs`.
14
+ - 📖 **Interactive Swagger UI**: Now fully supported in both standalone and **library mode**.
15
15
  - 🗄️ **Multi-DB Persistence**: Support for MongoDB, Postgres, and MySQL.
16
16
  - 🔄 **Hot-Swapping**: Switch SMTP credentials at runtime via the Dashboard.
17
17
  - 🛡️ **Production Ready**: Full STARTTLS support and descriptive error guards.
@@ -33,6 +33,7 @@ import express from 'express';
33
33
  import {
34
34
  contactRoutes,
35
35
  configRoutes,
36
+ swaggerRoutes, // ✨ New in v7.0
36
37
  dbService,
37
38
  DatabaseFactory
38
39
  } from 'mailer-advance';
@@ -45,9 +46,10 @@ const repository = DatabaseFactory.createRepository(process.env.DB_TYPE || 'mong
45
46
  await repository.connect();
46
47
  dbService.setRepository(repository);
47
48
 
48
- // 2. Mount API Routes
49
+ // 2. Mount API Routes & UI
49
50
  app.use('/api/mail', contactRoutes);
50
51
  app.use('/api/config', configRoutes);
52
+ app.use('/api-docs', swaggerRoutes); // ✨ Mount interactive docs
51
53
 
52
54
  app.listen(3000, () => {
53
55
  console.log('🚀 Engine active at http://localhost:3000');
@@ -59,9 +61,12 @@ app.listen(3000, () => {
59
61
 
60
62
  ## 📚 Interactive API Documentation (Swagger)
61
63
 
62
- V6.0.0 introduces a fully integrated **Swagger UI** for easier development and testing. Once your server is running, navigate to:
64
+ V7.0.0 enables the **Swagger UI** for library users. Unlike the standalone server where it's pre-mounted, library consumers must explicitly mount it:
63
65
 
64
- 👉 **`http://localhost:3000/api-docs`**
66
+ 👉 **`app.use('/api-docs', swaggerRoutes);`**
67
+
68
+ Once mounted, navigate to:
69
+ **`http://localhost:3000/api-docs`**
65
70
 
66
71
  From there, you can:
67
72
  - 🔍 **Explore**: See all available endpoints and their data structures.
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import contactRoutes from './src/routes/contact.routes.js';
2
2
  import configRoutes from './src/routes/config.routes.js';
3
+ import swaggerRoutes from './src/routes/swagger.routes.js';
3
4
  import mailService from './src/services/mail.service.js';
4
5
  import dbService from './src/services/db.service.js';
5
6
  import DatabaseFactory from './src/services/database.factory.js';
@@ -7,6 +8,7 @@ import DatabaseFactory from './src/services/database.factory.js';
7
8
  export {
8
9
  contactRoutes,
9
10
  configRoutes,
11
+ swaggerRoutes,
10
12
  mailService,
11
13
  dbService,
12
14
  DatabaseFactory
@@ -16,6 +18,7 @@ export {
16
18
  export default {
17
19
  contactRoutes,
18
20
  configRoutes,
21
+ swaggerRoutes,
19
22
  mailService,
20
23
  dbService,
21
24
  DatabaseFactory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailer-advance",
3
- "version": "6.0.0",
3
+ "version": "7.0.0",
4
4
  "description": "Advanced Node.js email service with dynamic SMTP configuration, multi-database support (MongoDB/SQL), and a built-in UI.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,10 @@
1
+ import express from 'express';
2
+ import swaggerUi from 'swagger-ui-express';
3
+ import swaggerSpec from '../config/swagger.config.js';
4
+
5
+ const router = express.Router();
6
+
7
+ router.use('/', swaggerUi.serve);
8
+ router.get('/', swaggerUi.setup(swaggerSpec));
9
+
10
+ export default router;