mailer-advance 1.0.0 → 1.0.2

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.
Files changed (4) hide show
  1. package/README.md +24 -6
  2. package/index.js +22 -0
  3. package/package.json +3 -5
  4. package/dist/server.js +0 -159823
package/README.md CHANGED
@@ -52,16 +52,34 @@ npm start
52
52
 
53
53
  ## Usage
54
54
 
55
- ### User Interface
55
+ ### 1. Standalone Service
56
56
  - **Send Email**: `http://localhost:3000/contact.html`
57
57
  - **List Configs**: `http://localhost:3000/list-configs.html`
58
58
  - **Add Config**: `http://localhost:3000/config.html`
59
59
 
60
- ### API Headers
61
- Send a `POST` request to `/api/contact` with:
62
- - `configId`: (Optional) ID of a saved SMTP configuration.
63
- - `to`: Recipient email.
64
- - `attachments`: Files (multipart/form-data).
60
+ ### 2. Integration into your Node.js App
61
+ You can use this package as a module in your existing Express application:
62
+
63
+ ```javascript
64
+ import express from 'express';
65
+ import { contactRoutes, configRoutes } from 'mailer-advance';
66
+
67
+ const app = express();
68
+
69
+ // Mount the mailer routes
70
+ app.use('/api/mail', contactRoutes);
71
+ app.use('/api/config', configRoutes);
72
+
73
+ app.listen(3001);
74
+ ```
75
+
76
+ ### API Usage
77
+ - `POST /api/contact`: Send email (supports attachments).
78
+ - `GET /api/config`: List all SMTP configurations.
79
+ - `POST /api/config`: Save/Update SMTP configuration.
80
+
81
+ ## Optimization
82
+ The package size is optimized to be extremely lightweight (~KBs) by excluding build artifacts and dev-dependencies from the final NPM bundle.
65
83
 
66
84
  ## License
67
85
  MIT
package/index.js ADDED
@@ -0,0 +1,22 @@
1
+ import contactRoutes from './src/routes/contact.routes.js';
2
+ import configRoutes from './src/routes/config.routes.js';
3
+ import mailService from './src/services/mail.service.js';
4
+ import dbService from './src/services/db.service.js';
5
+ import { DatabaseFactory } from './src/services/database.factory.js';
6
+
7
+ export {
8
+ contactRoutes,
9
+ configRoutes,
10
+ mailService,
11
+ dbService,
12
+ DatabaseFactory
13
+ };
14
+
15
+ // Default export for easy middleware usage
16
+ export default {
17
+ contactRoutes,
18
+ configRoutes,
19
+ mailService,
20
+ dbService,
21
+ DatabaseFactory
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailer-advance",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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": "src/server.js",
6
6
  "type": "module",
@@ -8,8 +8,7 @@
8
8
  "start": "node src/server.js",
9
9
  "dev": "nodemon --watch .env --watch src src/server.js",
10
10
  "build": "esbuild src/server.js --bundle --platform=node --format=esm --target=node20 --outfile=dist/server.js --external:express --external:nodemailer --external:dotenv --external:cors",
11
- "test": "echo \"Error: no test specified\" && exit 1",
12
- "prepublishOnly": "npm run build"
11
+ "test": "echo \"Error: no test specified\" && exit 1"
13
12
  },
14
13
  "publishConfig": {
15
14
  "access": "public"
@@ -29,14 +28,12 @@
29
28
  "files": [
30
29
  "src/",
31
30
  "public/",
32
- "dist/",
33
31
  "README.md",
34
32
  "index.js"
35
33
  ],
36
34
  "dependencies": {
37
35
  "cors": "^2.8.6",
38
36
  "dotenv": "^17.2.4",
39
- "esbuild": "^0.27.3",
40
37
  "express": "^5.2.1",
41
38
  "mongoose": "^9.1.6",
42
39
  "multer": "^2.0.2",
@@ -49,6 +46,7 @@
49
46
  "swagger-ui-express": "^5.0.1"
50
47
  },
51
48
  "devDependencies": {
49
+ "esbuild": "^0.27.3",
52
50
  "nodemon": "^3.1.11"
53
51
  }
54
52
  }