@technomoron/mail-magic 1.0.15 → 1.0.16
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 +33 -13
- package/package.json +6 -20
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @technomoron/mail-magic
|
|
2
2
|
|
|
3
|
-
Mail Magic is a TypeScript service for managing, templating, and delivering transactional emails. It exposes a small
|
|
3
|
+
Mail Magic is a TypeScript service for managing, templating, and delivering transactional emails. It exposes a small
|
|
4
|
+
REST API built on `@technomoron/api-server-base`, persists data with Sequelize/SQLite, and renders outbound messages
|
|
5
|
+
with Nunjucks templates.
|
|
4
6
|
|
|
5
7
|
## Features
|
|
6
8
|
|
|
@@ -16,7 +18,8 @@ Mail Magic is a TypeScript service for managing, templating, and delivering tran
|
|
|
16
18
|
1. Clone the repository: `git clone git@github.com:technomoron/mail-magic.git`
|
|
17
19
|
2. Install dependencies: `npm install`
|
|
18
20
|
3. Create your environment file: copy `.env-dist` to `.env` and adjust values
|
|
19
|
-
4. Populate the config directory (defaults to `./data/`; see `config-example/` for a reference layout). You can point
|
|
21
|
+
4. Populate the config directory (defaults to `./data/`; see `config-example/` for a reference layout). You can point
|
|
22
|
+
`CONFIG_PATH` at `./config` to use the bundled sample data.
|
|
20
23
|
5. Build the project: `npm run build`
|
|
21
24
|
6. Start the API server: `npm run start`
|
|
22
25
|
|
|
@@ -24,22 +27,38 @@ During development you can run `npm run dev` for a watch mode that recompiles on
|
|
|
24
27
|
|
|
25
28
|
## Configuration
|
|
26
29
|
|
|
27
|
-
- **Environment variables** are defined in `src/store/envloader.ts`. Important settings include SMTP credentials, API
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- **
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
- **Environment variables** are defined in `src/store/envloader.ts`. Important settings include SMTP credentials, API
|
|
31
|
+
host/port, the config directory path, database options, and `ADMIN_ENABLED`/`ADMIN_APP_PATH` to control the admin
|
|
32
|
+
UI/API.
|
|
33
|
+
- **Config directory** (`CONFIG_PATH`) contains JSON seed data (`init-data.json`), optional API key files, and template
|
|
34
|
+
assets. Each domain now lives directly under the config root (for example `data/example.com/form-template/…`). Use an
|
|
35
|
+
absolute path or a relative one like `../data` when you want the config outside the repo. Review `config-example/` for
|
|
36
|
+
the recommended layout, in particular the `form-template/` and `tx-template/` folders used for compiled Nunjucks
|
|
37
|
+
templates.
|
|
38
|
+
- **Database** defaults to SQLite (`maildata.db`). You can switch dialects by updating the environment options if your
|
|
39
|
+
deployment requires another database.
|
|
40
|
+
- **Uploads** default to `<CONFIG_PATH>/<domain>/uploads` via `UPLOAD_PATH=./{domain}/uploads`. Set a fixed path if you
|
|
41
|
+
prefer a shared upload directory.
|
|
42
|
+
|
|
43
|
+
When `DB_AUTO_RELOAD` is enabled the service watches `init-data.json` and refreshes templates and forms without a
|
|
44
|
+
restart.
|
|
33
45
|
|
|
34
46
|
### Admin UI
|
|
35
47
|
|
|
36
|
-
The server mounts the admin UI at `/` only when `ADMIN_ENABLED` is true and the `@technomoron/mail-magic-admin` package
|
|
48
|
+
The server mounts the admin UI at `/` only when `ADMIN_ENABLED` is true and the `@technomoron/mail-magic-admin` package
|
|
49
|
+
is installed. You can point `ADMIN_APP_PATH` at a dist folder (or its parent) to override the package-provided build.
|
|
50
|
+
The admin API module is loaded from the admin package as well. This is a placeholder Vue app today, but it is already
|
|
51
|
+
wired so future admin features can live there without changing the server routing.
|
|
37
52
|
|
|
38
53
|
### Template assets and inline resources
|
|
39
54
|
|
|
40
|
-
- Keep any non-inline files (images, attachments, etc.) under `<CONFIG_PATH>/<domain>/assets`. Mail Magic rewrites
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
- Keep any non-inline files (images, attachments, etc.) under `<CONFIG_PATH>/<domain>/assets`. Mail Magic rewrites
|
|
56
|
+
`asset('logo.png')` using `ASSET_ROUTE` (default `/asset`) and a base URL from `ASSET_PUBLIC_BASE` (or `API_URL` if
|
|
57
|
+
unset). The default output looks like `http://localhost:3776/asset/<domain>/logo.png`.
|
|
58
|
+
- Pass `true` as the second argument when you want to embed a file as an inline CID attachment:
|
|
59
|
+
`asset('logo.png', true)` stores the file in Nodemailer and rewrites the HTML to reference `cid:logo.png`.
|
|
60
|
+
- Avoid mixing template-type folders for assets; everything that should be linked externally belongs in the shared
|
|
61
|
+
`<domain>/assets` tree so it can be served for both form and transactional templates.
|
|
43
62
|
|
|
44
63
|
## API Overview
|
|
45
64
|
|
|
@@ -52,7 +71,8 @@ The server mounts the admin UI at `/` only when `ADMIN_ENABLED` is true and the
|
|
|
52
71
|
|
|
53
72
|
All routes are mounted under `API_BASE_PATH` (default `/api`), so the full path is typically `/api/v1/...`.
|
|
54
73
|
|
|
55
|
-
All authenticated routes expect an API token associated with a configured user. Attachments can be uploaded alongside
|
|
74
|
+
All authenticated routes expect an API token associated with a configured user. Attachments can be uploaded alongside
|
|
75
|
+
the `/v1/tx/message` request and are forwarded by Nodemailer.
|
|
56
76
|
|
|
57
77
|
## Available Scripts
|
|
58
78
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@technomoron/mail-magic",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,14 +17,6 @@
|
|
|
17
17
|
"url": "git+https://github.com/technomoron/mail-magic.git",
|
|
18
18
|
"directory": "packages/mail-magic"
|
|
19
19
|
},
|
|
20
|
-
"pnpm": {
|
|
21
|
-
"onlyBuiltDependencies": [
|
|
22
|
-
"core-js",
|
|
23
|
-
"@scarf/scarf",
|
|
24
|
-
"esbuild",
|
|
25
|
-
"sqlite3"
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
20
|
"scripts": {
|
|
29
21
|
"start": "node dist/index.js",
|
|
30
22
|
"dev": "NODE_ENV=development nodemon --watch 'src/**/*.ts' --watch 'config/**/*.*' --watch '.env' --exec 'tsx' src/index.ts",
|
|
@@ -35,12 +27,12 @@
|
|
|
35
27
|
"test": "vitest run",
|
|
36
28
|
"test:watch": "vitest",
|
|
37
29
|
"scrub": "rm -rf ./node_modules/ ./dist/ pnpm-lock.yaml",
|
|
38
|
-
"lint": "eslint --no-error-on-unmatched-pattern --ext .js,.cjs,.mjs,.ts,.mts,.tsx,.vue,.json ./",
|
|
39
|
-
"lintfix": "eslint --fix --no-error-on-unmatched-pattern --ext .js,.cjs,.mjs,.ts,.mts,.tsx,.vue,.json ./",
|
|
40
|
-
"pretty": "prettier --write \"**/*.{js,jsx,cjs,mjs,ts,tsx,mts,vue,json,md}\"",
|
|
30
|
+
"lint": "node ../../node_modules/eslint/bin/eslint.js --config ../../eslint.config.mjs --no-error-on-unmatched-pattern --ext .js,.cjs,.mjs,.ts,.mts,.tsx,.vue,.json ./",
|
|
31
|
+
"lintfix": "node ../../node_modules/eslint/bin/eslint.js --config ../../eslint.config.mjs --fix --no-error-on-unmatched-pattern --ext .js,.cjs,.mjs,.ts,.mts,.tsx,.vue,.json ./",
|
|
32
|
+
"pretty": "node ../../node_modules/prettier/bin/prettier.cjs --config ../../.prettierrc --write \"**/*.{js,jsx,cjs,mjs,ts,tsx,mts,vue,json,md}\"",
|
|
41
33
|
"format": "npm run lintfix && npm run pretty",
|
|
42
34
|
"cleanbuild": "rm -rf ./dist/ && npm run format && npm run build",
|
|
43
|
-
"lintconfig": "node lintconfig.cjs"
|
|
35
|
+
"lintconfig": "node ../../lintconfig.cjs"
|
|
44
36
|
},
|
|
45
37
|
"keywords": [],
|
|
46
38
|
"author": "Bjørn Erik Jacobsen",
|
|
@@ -66,19 +58,13 @@
|
|
|
66
58
|
"zod": "^4.1.5"
|
|
67
59
|
},
|
|
68
60
|
"devDependencies": {
|
|
61
|
+
"@types/express": "^4.17.21",
|
|
69
62
|
"@types/html-to-text": "^9.0.4",
|
|
70
63
|
"@types/nodemailer": "^6.4.19",
|
|
71
64
|
"@types/nunjucks": "^3.2.6",
|
|
72
65
|
"@types/supertest": "^6.0.3",
|
|
73
|
-
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
74
|
-
"@typescript-eslint/parser": "^8.50.1",
|
|
75
|
-
"eslint": "^9.39.2",
|
|
76
|
-
"eslint-config-prettier": "^10.1.8",
|
|
77
|
-
"eslint-plugin-import": "^2.32.0",
|
|
78
|
-
"jsonc-eslint-parser": "^2.4.1",
|
|
79
66
|
"mailparser": "^3.9.1",
|
|
80
67
|
"nodemon": "^3.1.10",
|
|
81
|
-
"prettier": "^3.7.4",
|
|
82
68
|
"smtp-server": "^3.18.0",
|
|
83
69
|
"supertest": "^7.1.4",
|
|
84
70
|
"tsx": "^4.20.5",
|