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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notifkit",
3
- "version": "0.1.9",
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",
@@ -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 node scripts/create-admin.mjs
7
- * node scripts/create-admin.mjs admin@example.com secret [username] [role]
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 username = process.argv[4] || process.env.ADMIN_USERNAME || null;
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: node scripts/create-admin.mjs <email> <password> [username] [role]");
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, username, password_hash, role)
48
- VALUES (${normalizedEmail}, ${normalizedUsername}, ${passwordHash}, ${role})
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, username, role, created_at, updated_at
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)