notifkit 0.1.9 → 0.1.10
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 +66 -72
- package/dist/index.d.mts +10 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{main-JdOvJ70b.mjs → main-39DtKrX4.mjs} +2 -2
- package/dist/{main-JdOvJ70b.mjs.map → main-39DtKrX4.mjs.map} +1 -1
- package/dist/{main-AO0JaY5z.mjs → main-B3iQrl3t.mjs} +2 -2
- package/dist/{main-AO0JaY5z.mjs.map → main-B3iQrl3t.mjs.map} +1 -1
- package/dist/{main-CyeQ_yDt.mjs → main-BM8DH3v3.mjs} +2 -2
- package/dist/{main-CyeQ_yDt.mjs.map → main-BM8DH3v3.mjs.map} +1 -1
- package/dist/{main-D19Wxs0x.mjs → main-BgmT1MPe.mjs} +2 -2
- package/dist/{main-D19Wxs0x.mjs.map → main-BgmT1MPe.mjs.map} +1 -1
- package/dist/{main-BPbPnBIG.mjs → main-BiFiOX9D.mjs} +2 -2
- package/dist/{main-BPbPnBIG.mjs.map → main-BiFiOX9D.mjs.map} +1 -1
- package/dist/{main-DSmh1e-V.mjs → main-C9s-2ArH.mjs} +2 -2
- package/dist/{main-DSmh1e-V.mjs.map → main-C9s-2ArH.mjs.map} +1 -1
- package/dist/{main-BMYSYcv2.mjs → main-Cqo3rSb5.mjs} +2 -2
- package/dist/{main-BMYSYcv2.mjs.map → main-Cqo3rSb5.mjs.map} +1 -1
- package/dist/{main-4Wyge9ms.mjs → main-Dz2sUh3c.mjs} +2 -2
- package/dist/{main-4Wyge9ms.mjs.map → main-Dz2sUh3c.mjs.map} +1 -1
- package/dist/{src-CGmXRfsM.mjs → src-QiTu5e_a.mjs} +20 -17
- package/dist/{src-CGmXRfsM.mjs.map → src-QiTu5e_a.mjs.map} +1 -1
- package/package.json +1 -1
- package/scripts/create-admin.mjs +8 -11
- package/src/server.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notifkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Self-hosted notification infrastructure. One call delivers to email, SMS, push, and webhook — routed by preference, quiet hours, and consent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "devkitshq",
|
package/scripts/create-admin.mjs
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Create or update an admin user for the Notifkit Dashboard.
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
6
|
-
* ADMIN_EMAIL=admin@example.com ADMIN_PASSWORD=secret
|
|
7
|
-
*
|
|
6
|
+
* ADMIN_EMAIL=admin@example.com ADMIN_PASSWORD=secret npx notifkit-create-admin
|
|
7
|
+
* npx notifkit-create-admin admin@example.com secret [role]
|
|
8
|
+
* node scripts/create-admin.mjs admin@example.com secret [role]
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
import { config } from "dotenv";
|
|
@@ -25,11 +26,10 @@ async function hashPassword(password) {
|
|
|
25
26
|
|
|
26
27
|
const email = process.argv[2] || process.env.ADMIN_EMAIL;
|
|
27
28
|
const password = process.argv[3] || process.env.ADMIN_PASSWORD;
|
|
28
|
-
const
|
|
29
|
-
const role = process.argv[5] || "admin";
|
|
29
|
+
const role = process.argv[4] || "admin";
|
|
30
30
|
|
|
31
31
|
if (!email || !password) {
|
|
32
|
-
console.error("Usage:
|
|
32
|
+
console.error("Usage: npx notifkit-create-admin <email> <password> [role]");
|
|
33
33
|
console.error("Or set ADMIN_EMAIL and ADMIN_PASSWORD in environment.");
|
|
34
34
|
process.exit(1);
|
|
35
35
|
}
|
|
@@ -41,23 +41,20 @@ const sql = postgres(databaseUrl);
|
|
|
41
41
|
try {
|
|
42
42
|
const passwordHash = await hashPassword(password);
|
|
43
43
|
const normalizedEmail = email.trim().toLowerCase();
|
|
44
|
-
const normalizedUsername = username ? username.trim() : null;
|
|
45
44
|
|
|
46
45
|
const rows = await sql`
|
|
47
|
-
INSERT INTO admin_users (email,
|
|
48
|
-
VALUES (${normalizedEmail}, ${
|
|
46
|
+
INSERT INTO admin_users (email, password_hash, role)
|
|
47
|
+
VALUES (${normalizedEmail}, ${passwordHash}, ${role})
|
|
49
48
|
ON CONFLICT (email) DO UPDATE
|
|
50
49
|
SET password_hash = EXCLUDED.password_hash,
|
|
51
|
-
username = COALESCE(EXCLUDED.username, admin_users.username),
|
|
52
50
|
role = EXCLUDED.role,
|
|
53
51
|
updated_at = NOW()
|
|
54
|
-
RETURNING id, email,
|
|
52
|
+
RETURNING id, email, role, created_at, updated_at
|
|
55
53
|
`;
|
|
56
54
|
|
|
57
55
|
console.log("\nAdmin user successfully saved:\n");
|
|
58
56
|
console.log(` ID: ${rows[0].id}`);
|
|
59
57
|
console.log(` Email: ${rows[0].email}`);
|
|
60
|
-
console.log(` Username: ${rows[0].username || "(none)"}`);
|
|
61
58
|
console.log(` Role: ${rows[0].role}\n`);
|
|
62
59
|
} catch (err) {
|
|
63
60
|
console.error(`Failed to create admin: ${err.message}`);
|
package/src/server.ts
CHANGED
|
@@ -10,6 +10,11 @@ export interface NotifkitOptions {
|
|
|
10
10
|
port?: number;
|
|
11
11
|
logLevel?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent";
|
|
12
12
|
nodeEnv?: "development" | "test" | "production";
|
|
13
|
+
adminUser?: {
|
|
14
|
+
email: string;
|
|
15
|
+
password: string;
|
|
16
|
+
username?: string;
|
|
17
|
+
};
|
|
13
18
|
services: (
|
|
14
19
|
"api" | "delivery" | "engine" | "enricher" | "scheduler" | "ai" | "workflow" | "events" | "all"
|
|
15
20
|
)[];
|
|
@@ -69,6 +74,11 @@ export class NotifkitServer extends EventEmitter {
|
|
|
69
74
|
if (this.options.port) process.env.PORT = String(this.options.port);
|
|
70
75
|
if (this.options.logLevel) process.env.LOG_LEVEL = this.options.logLevel;
|
|
71
76
|
if (this.options.nodeEnv) process.env.NODE_ENV = this.options.nodeEnv;
|
|
77
|
+
if (this.options.adminUser?.email) process.env.ADMIN_EMAIL = this.options.adminUser.email;
|
|
78
|
+
if (this.options.adminUser?.password)
|
|
79
|
+
process.env.ADMIN_PASSWORD = this.options.adminUser.password;
|
|
80
|
+
if (this.options.adminUser?.username)
|
|
81
|
+
process.env.ADMIN_USERNAME = this.options.adminUser.username;
|
|
72
82
|
if (this.options.workerConcurrency)
|
|
73
83
|
process.env.WORKER_CONCURRENCY = String(this.options.workerConcurrency);
|
|
74
84
|
if (this.options.redisOptions?.maxQueueLength)
|