nuxt-users 1.1.3 → 1.1.4

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/CHANGELOG.md CHANGED
@@ -1,6 +1,68 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## v1.1.4
5
+
6
+ [compare changes](https://github.com/rrd108/nuxt-users/compare/v1.1.0...v1.1.4)
7
+
8
+ ### 🩹 Fixes
9
+
10
+ - CLI tool for database management ([0a4793f](https://github.com/rrd108/nuxt-users/commit/0a4793f))
11
+ - Handling cli commands ([120c396](https://github.com/rrd108/nuxt-users/commit/120c396))
12
+ - Database handling and setup ([11ddc20](https://github.com/rrd108/nuxt-users/commit/11ddc20))
13
+ - Proper check for migrations table ([08701a1](https://github.com/rrd108/nuxt-users/commit/08701a1))
14
+ - Migration command in warning message ([1a62e50](https://github.com/rrd108/nuxt-users/commit/1a62e50))
15
+ - Improves database connector error handling ([db3b670](https://github.com/rrd108/nuxt-users/commit/db3b670))
16
+ - Use sql connector defined in nuxt.config ([b37900d](https://github.com/rrd108/nuxt-users/commit/b37900d))
17
+ - Module metadata and build process ([3da5410](https://github.com/rrd108/nuxt-users/commit/3da5410))
18
+ - **ci:** Install optional dependencies ([38d6ee8](https://github.com/rrd108/nuxt-users/commit/38d6ee8))
19
+ - Adds necessary database drivers for testing ([f1815f4](https://github.com/rrd108/nuxt-users/commit/f1815f4))
20
+ - **ci:** Installs peer dependencies in CI workflows ([423d4e9](https://github.com/rrd108/nuxt-users/commit/423d4e9))
21
+ - Test paths ([047f0e8](https://github.com/rrd108/nuxt-users/commit/047f0e8))
22
+ - Type errors ([3d5b35c](https://github.com/rrd108/nuxt-users/commit/3d5b35c))
23
+ - Consolidates build config and external deps ([48b4980](https://github.com/rrd108/nuxt-users/commit/48b4980))
24
+ - **ci:** Downgrade mariadb ([b1be244](https://github.com/rrd108/nuxt-users/commit/b1be244))
25
+ - Adds db0 to external dependencies ([b276c58](https://github.com/rrd108/nuxt-users/commit/b276c58))
26
+
27
+ ### 💅 Refactors
28
+
29
+ - CLI commands to use environment variables ([3fc6c9f](https://github.com/rrd108/nuxt-users/commit/3fc6c9f))
30
+ - Remove unused types ([06b5e9f](https://github.com/rrd108/nuxt-users/commit/06b5e9f))
31
+ - Database connection logic ([f5baadf](https://github.com/rrd108/nuxt-users/commit/f5baadf))
32
+ - Moves user existence check to user utils ([62cc871](https://github.com/rrd108/nuxt-users/commit/62cc871))
33
+ - Remove unused options ([b391013](https://github.com/rrd108/nuxt-users/commit/b391013))
34
+ - Adds a color palette and styles login forms ([d3bffab](https://github.com/rrd108/nuxt-users/commit/d3bffab))
35
+ - Adds color palette and improves styling ([7cfab67](https://github.com/rrd108/nuxt-users/commit/7cfab67))
36
+ - Db check to plugin ([d466e2f](https://github.com/rrd108/nuxt-users/commit/d466e2f))
37
+ - Consolidates utils and CLI build ([21e9f3c](https://github.com/rrd108/nuxt-users/commit/21e9f3c))
38
+ - Remove unused option ([d9e3525](https://github.com/rrd108/nuxt-users/commit/d9e3525))
39
+ - Utils import paths ([e3b59c3](https://github.com/rrd108/nuxt-users/commit/e3b59c3))
40
+ - Module utils and improves CLI output ([e80b160](https://github.com/rrd108/nuxt-users/commit/e80b160))
41
+
42
+ ### 🏡 Chore
43
+
44
+ - **release:** V1.1.0 ([bfc24f6](https://github.com/rrd108/nuxt-users/commit/bfc24f6))
45
+ - Adds script to deploy documentation to server ([81f7f74](https://github.com/rrd108/nuxt-users/commit/81f7f74))
46
+ - Adds script to deploy documentation ([7e2f642](https://github.com/rrd108/nuxt-users/commit/7e2f642))
47
+ - **release:** V1.1.1 ([e3bda8a](https://github.com/rrd108/nuxt-users/commit/e3bda8a))
48
+ - **release:** V1.1.2 ([3a2d2ae](https://github.com/rrd108/nuxt-users/commit/3a2d2ae))
49
+ - **release:** V1.1.3 ([b32a05f](https://github.com/rrd108/nuxt-users/commit/b32a05f))
50
+ - Updates dependencies in yarn.lock ([f29a369](https://github.com/rrd108/nuxt-users/commit/f29a369))
51
+ - Adds nodemailer to externals and dependencies ([b717d49](https://github.com/rrd108/nuxt-users/commit/b717d49))
52
+ - Removes stub build from dev prepare script ([dd96376](https://github.com/rrd108/nuxt-users/commit/dd96376))
53
+ - Remove examples ([d2f5c04](https://github.com/rrd108/nuxt-users/commit/d2f5c04))
54
+ - Remove comments ([6b45d71](https://github.com/rrd108/nuxt-users/commit/6b45d71))
55
+ - Renames unbuild config file ([bd7299f](https://github.com/rrd108/nuxt-users/commit/bd7299f))
56
+
57
+ ### ✅ Tests
58
+
59
+ - Cleanup added ([50369a9](https://github.com/rrd108/nuxt-users/commit/50369a9))
60
+ - Ensures database cleanup on test completion ([a1a528c](https://github.com/rrd108/nuxt-users/commit/a1a528c))
61
+
62
+ ### ❤️ Contributors
63
+
64
+ - Rrd108 ([@rrd108](https://github.com/rrd108))
65
+
4
66
  ## v1.1.3
5
67
 
6
68
  [compare changes](https://github.com/rrd108/nuxt-users/compare/v1.1.0...v1.1.3)
package/README.md CHANGED
@@ -67,3 +67,15 @@ cd docs && yarn dev
67
67
  ## License
68
68
 
69
69
  MIT
70
+
71
+ ## Dev misc
72
+
73
+ ### Using yalc
74
+
75
+ ```bash
76
+ # Publish the module's new version
77
+ yalc publish
78
+
79
+ # Install the module in the consumer app
80
+ yalc add nuxt-users
81
+ ```
package/dist/cli.mjs CHANGED
@@ -1,346 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
- import bcrypt from 'bcrypt';
3
+ import 'db0';
4
+ import 'bcrypt';
5
+ import { r as runMigrations, a as createUser$1, d as createUsersTable$1, e as createPersonalAccessTokensTable$1, g as createPasswordResetTokensTable$1, h as createMigrationsTable$1 } from './shared/nuxt-users.eSQUrS6l.mjs';
4
6
  import { loadNuxt } from '@nuxt/kit';
5
7
 
6
- function sqlTemplate(strings, ...values) {
7
- if (!isTemplateStringsArray(strings) || !Array.isArray(values)) {
8
- throw new Error("[db0] invalid template invocation");
9
- }
10
- const staticIndexes = [];
11
- let result = strings[0] || "";
12
- for (let i = 1; i < strings.length; i++) {
13
- if (result.endsWith("{") && strings[i].startsWith("}")) {
14
- result = result.slice(0, -1) + values[i - 1] + strings[i].slice(1);
15
- staticIndexes.push(i - 1);
16
- continue;
17
- }
18
- result += `?${strings[i] ?? ""}`;
19
- }
20
- const dynamicValues = values.filter((_, i) => !staticIndexes.includes(i));
21
- return [result.trim(), dynamicValues];
22
- }
23
- function isTemplateStringsArray(strings) {
24
- return Array.isArray(strings) && "raw" in strings && Array.isArray(strings.raw);
25
- }
26
-
27
- const SQL_SELECT_RE = /^select/i;
28
- const SQL_RETURNING_RE = /[\s]returning[\s]/i;
29
- const DIALECTS_WITH_RET = /* @__PURE__ */ new Set(["postgresql", "sqlite"]);
30
- function createDatabase(connector) {
31
- return {
32
- get dialect() {
33
- return connector.dialect;
34
- },
35
- getInstance() {
36
- return connector.getInstance();
37
- },
38
- exec: (sql) => {
39
- return Promise.resolve(connector.exec(sql));
40
- },
41
- prepare: (sql) => {
42
- return connector.prepare(sql);
43
- },
44
- sql: async (strings, ...values) => {
45
- const [sql, params] = sqlTemplate(strings, ...values);
46
- if (SQL_SELECT_RE.test(sql) || // prettier-ignore
47
- DIALECTS_WITH_RET.has(connector.dialect) && SQL_RETURNING_RE.test(sql)) {
48
- const rows = await connector.prepare(sql).all(...params);
49
- return {
50
- rows,
51
- success: true
52
- };
53
- } else {
54
- const res = await connector.prepare(sql).run(...params);
55
- return res;
56
- }
57
- }
58
- };
59
- }
60
-
61
- const getConnector = async (name) => {
62
- switch (name) {
63
- case "mysql":
64
- return (await import('./chunks/mysql2.mjs')).default;
65
- case "postgresql":
66
- return (await import('./chunks/postgresql.mjs')).default;
67
- case "sqlite":
68
- return (await import('./chunks/better-sqlite3.mjs')).default;
69
- default:
70
- throw new Error(`Unsupported database connector: ${name}`);
71
- }
72
- };
73
- const useDb = async (options) => {
74
- const connectorName = options.connector.name;
75
- const connector = await getConnector(connectorName);
76
- const connectorOptions = { ...options.connector.options };
77
- if (connectorName !== "sqlite") {
78
- delete connectorOptions.path;
79
- }
80
- try {
81
- return createDatabase(connector(connectorOptions));
82
- } catch (error) {
83
- console.warn(`[Nuxt Users DB] \u26A0\uFE0F Failed to connect to ${connectorName} database:`, error instanceof Error ? error.message : "Unknown error");
84
- throw error;
85
- }
86
- };
87
-
88
- const createUser$1 = async (userData, options) => {
89
- const db = await useDb(options);
90
- const usersTable = options.tables.users;
91
- const hashedPassword = await bcrypt.hash(userData.password, 10);
92
- await db.sql`
93
- INSERT INTO {${usersTable}} (email, name, password, created_at, updated_at)
94
- VALUES (${userData.email}, ${userData.name}, ${hashedPassword}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
95
- `;
96
- const result = await db.sql`SELECT id, email, name, created_at, updated_at FROM {${usersTable}} WHERE email = ${userData.email}`;
97
- if (result.rows.length === 0) {
98
- throw new Error("Failed to retrieve created user.");
99
- }
100
- const user = result.rows[0];
101
- return {
102
- id: user.id,
103
- email: user.email,
104
- name: user.name,
105
- created_at: user.created_at instanceof Date ? user.created_at.toISOString() : user.created_at,
106
- updated_at: user.updated_at instanceof Date ? user.updated_at.toISOString() : user.updated_at
107
- };
108
- };
109
-
110
- const createUsersTable$1 = async (options) => {
111
- const connectorName = options.connector.name;
112
- const db = await useDb(options);
113
- const tableName = options.tables.users;
114
- console.log(`[DB:Create ${connectorName} Users Table] Creating ${tableName}...`);
115
- if (connectorName === "sqlite") {
116
- await db.sql`
117
- CREATE TABLE IF NOT EXISTS {${tableName}} (
118
- id INTEGER PRIMARY KEY AUTOINCREMENT,
119
- email TEXT NOT NULL UNIQUE,
120
- name TEXT NOT NULL,
121
- password TEXT NOT NULL,
122
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
123
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
124
- )
125
- `;
126
- }
127
- if (connectorName === "mysql") {
128
- await db.sql`
129
- CREATE TABLE IF NOT EXISTS {${tableName}} (
130
- id INT AUTO_INCREMENT PRIMARY KEY,
131
- email VARCHAR(255) NOT NULL UNIQUE,
132
- name VARCHAR(255) NOT NULL,
133
- password VARCHAR(255) NOT NULL,
134
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
135
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
136
- )
137
- `;
138
- }
139
- if (connectorName === "postgresql") {
140
- await db.sql`
141
- CREATE TABLE IF NOT EXISTS {${tableName}} (
142
- id SERIAL PRIMARY KEY,
143
- email VARCHAR(255) NOT NULL UNIQUE,
144
- name VARCHAR(255) NOT NULL,
145
- password VARCHAR(255) NOT NULL,
146
- created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
147
- updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
148
- )
149
- `;
150
- }
151
- console.log(`[DB:Create ${connectorName} Users Table] Fields: id, email, name, password, created_at, updated_at \u2705`);
152
- };
153
-
154
- const createPersonalAccessTokensTable$1 = async (options) => {
155
- const connectorName = options.connector.name;
156
- const db = await useDb(options);
157
- const tableName = options.tables.personalAccessTokens;
158
- console.log(`[DB:Create Personal Access Tokens ${connectorName} Table] Creating ${tableName} table with ${connectorName} connector...`);
159
- if (connectorName === "sqlite") {
160
- await db.sql`
161
- CREATE TABLE IF NOT EXISTS {${tableName}} (
162
- id INTEGER PRIMARY KEY AUTOINCREMENT,
163
- tokenable_type TEXT NOT NULL,
164
- tokenable_id INTEGER NOT NULL,
165
- name TEXT NOT NULL,
166
- token TEXT NOT NULL UNIQUE,
167
- abilities TEXT,
168
- last_used_at DATETIME,
169
- expires_at DATETIME,
170
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
171
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
172
- )
173
- `;
174
- }
175
- if (connectorName === "mysql") {
176
- await db.sql`
177
- CREATE TABLE IF NOT EXISTS {${tableName}} (
178
- id INT AUTO_INCREMENT PRIMARY KEY,
179
- tokenable_type VARCHAR(255) NOT NULL,
180
- tokenable_id INT NOT NULL,
181
- name VARCHAR(255) NOT NULL,
182
- token VARCHAR(255) NOT NULL UNIQUE,
183
- abilities TEXT,
184
- last_used_at DATETIME,
185
- expires_at DATETIME,
186
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
187
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
188
- )
189
- `;
190
- }
191
- if (connectorName === "postgresql") {
192
- await db.sql`
193
- CREATE TABLE IF NOT EXISTS {${tableName}} (
194
- id SERIAL PRIMARY KEY,
195
- tokenable_type VARCHAR(255) NOT NULL,
196
- tokenable_id INT NOT NULL,
197
- name VARCHAR(255) NOT NULL,
198
- token VARCHAR(255) NOT NULL UNIQUE,
199
- abilities TEXT,
200
- last_used_at TIMESTAMPTZ,
201
- expires_at TIMESTAMPTZ,
202
- created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
203
- updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
204
- )
205
- `;
206
- }
207
- console.log(`[DB:Create Personal Access Tokens ${connectorName} Table] Fields: id, tokenable_type, tokenable_id, name, token, abilities, last_used_at, expires_at, created_at, updated_at \u2705`);
208
- };
209
-
210
- const createPasswordResetTokensTable$1 = async (options) => {
211
- const connectorName = options.connector.name;
212
- const db = await useDb(options);
213
- const tableName = options.tables.passwordResetTokens;
214
- console.log(`[DB:Create Password Reset Tokens ${connectorName} Table] Creating ${tableName} table with ${connectorName} connector...`);
215
- if (connectorName === "sqlite") {
216
- await db.sql`
217
- CREATE TABLE IF NOT EXISTS {${tableName}} (
218
- id INTEGER PRIMARY KEY AUTOINCREMENT,
219
- email TEXT NOT NULL,
220
- token TEXT NOT NULL UNIQUE,
221
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP
222
- )
223
- `;
224
- }
225
- if (connectorName === "mysql") {
226
- await db.sql`
227
- CREATE TABLE IF NOT EXISTS {${tableName}} (
228
- id INT AUTO_INCREMENT PRIMARY KEY,
229
- email VARCHAR(255) NOT NULL,
230
- token VARCHAR(255) NOT NULL UNIQUE,
231
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP
232
- )
233
- `;
234
- }
235
- if (connectorName === "postgresql") {
236
- await db.sql`
237
- CREATE TABLE IF NOT EXISTS {${tableName}} (
238
- id SERIAL PRIMARY KEY,
239
- email VARCHAR(255) NOT NULL,
240
- token VARCHAR(255) NOT NULL UNIQUE,
241
- created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
242
- )
243
- `;
244
- }
245
- await db.sql`CREATE INDEX IF NOT EXISTS idx_password_reset_tokens_email ON {${tableName}} (email)`;
246
- await db.sql`CREATE INDEX IF NOT EXISTS idx_password_reset_tokens_token ON {${tableName}} (token)`;
247
- console.log(`[DB:Create Password Reset Tokens ${connectorName} Table] Fields: id, email, token, created_at \u2705`);
248
- };
249
-
250
- const createMigrationsTable$1 = async (options) => {
251
- const connectorName = options.connector.name;
252
- const db = await useDb(options);
253
- const tableName = "migrations";
254
- console.log(`[DB:Create Migrations ${connectorName} Table] Creating ${tableName} table with ${connectorName} connector...`);
255
- if (connectorName === "sqlite") {
256
- await db.sql`
257
- CREATE TABLE IF NOT EXISTS {${tableName}} (
258
- id INTEGER PRIMARY KEY AUTOINCREMENT,
259
- name TEXT NOT NULL UNIQUE,
260
- executed_at DATETIME DEFAULT CURRENT_TIMESTAMP
261
- )
262
- `;
263
- }
264
- if (connectorName === "mysql") {
265
- await db.sql`
266
- CREATE TABLE IF NOT EXISTS {${tableName}} (
267
- id INT AUTO_INCREMENT PRIMARY KEY,
268
- name VARCHAR(255) NOT NULL UNIQUE,
269
- executed_at DATETIME DEFAULT CURRENT_TIMESTAMP
270
- )
271
- `;
272
- }
273
- if (connectorName === "postgresql") {
274
- await db.sql`
275
- CREATE TABLE IF NOT EXISTS {${tableName}} (
276
- id SERIAL PRIMARY KEY,
277
- name VARCHAR(255) NOT NULL UNIQUE,
278
- executed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
279
- )
280
- `;
281
- }
282
- console.log(`[DB:Create Migrations ${connectorName} Table] successfull \u2705`);
283
- };
284
-
285
- const migrations = [
286
- {
287
- name: "create_migrations_table",
288
- run: createMigrationsTable$1
289
- },
290
- {
291
- name: "create_users_table",
292
- run: createUsersTable$1
293
- },
294
- {
295
- name: "create_personal_access_tokens_table",
296
- run: createPersonalAccessTokensTable$1
297
- },
298
- {
299
- name: "create_password_reset_tokens_table",
300
- run: createPasswordResetTokensTable$1
301
- }
302
- ];
303
- const getAppliedMigrations = async (options) => {
304
- const db = await useDb(options);
305
- try {
306
- const result = await db.sql`SELECT name FROM migrations ORDER BY id`;
307
- return result.rows.map((row) => row.name);
308
- } catch {
309
- return [];
310
- }
311
- };
312
- const markMigrationAsApplied = async (options, migrationName) => {
313
- const db = await useDb(options);
314
- await db.sql`INSERT INTO migrations (name) VALUES (${migrationName})`;
315
- };
316
- const runMigrations = async (options) => {
317
- console.log("[Nuxt Users] Starting migration system...");
318
- await createMigrationsTable$1(options);
319
- const appliedMigrations = await getAppliedMigrations(options);
320
- console.log(`[Nuxt Users] Applied migrations: ${appliedMigrations.join(", ")}`);
321
- const pendingMigrations = migrations.filter((migration) => !appliedMigrations.includes(migration.name));
322
- if (pendingMigrations.length === 0) {
323
- console.log("[Nuxt Users] No pending migrations to run.");
324
- return;
325
- }
326
- console.log(`[Nuxt Users] Found ${pendingMigrations.length} pending migrations:`);
327
- pendingMigrations.forEach((migration) => {
328
- console.log(` - ${migration.name}`);
329
- });
330
- for (const migration of pendingMigrations) {
331
- console.log(`[Nuxt Users] Running migration: ${migration.name}`);
332
- try {
333
- await migration.run(options);
334
- await markMigrationAsApplied(options, migration.name);
335
- console.log(`[Nuxt Users] \u2713 Migration ${migration.name} successfull \u2705`);
336
- } catch (error) {
337
- console.error(`[Nuxt Users] \u2717 Migration ${migration.name} failed:`, error);
338
- throw error;
339
- }
340
- }
341
- console.log("[Nuxt Users] All migrations successfull \u2705");
342
- };
343
-
344
8
  const defaultOptions = {
345
9
  connector: {
346
10
  name: "sqlite",
@@ -414,10 +78,28 @@ const migrate = defineCommand({
414
78
  },
415
79
  async run() {
416
80
  console.log("[Nuxt Users] Starting migration system...");
417
- const options = getOptionsFromEnv();
81
+ let options;
82
+ try {
83
+ console.log("[Nuxt Users] Loading Nuxt project...");
84
+ const nuxt = await loadNuxt({ cwd: process.cwd() });
85
+ const nuxtUsersConfig = nuxt.options.runtimeConfig?.nuxtUsers;
86
+ await nuxt.close();
87
+ if (nuxtUsersConfig) {
88
+ console.log("[Nuxt Users] Using configuration from Nuxt project");
89
+ options = nuxtUsersConfig;
90
+ } else {
91
+ console.log("[Nuxt Users] No nuxt-users configuration found, using environment variables");
92
+ options = getOptionsFromEnv();
93
+ }
94
+ } catch (error) {
95
+ console.log("[Nuxt Users] Could not load Nuxt project, using environment variables");
96
+ console.error(error);
97
+ options = getOptionsFromEnv();
98
+ }
418
99
  try {
419
100
  await runMigrations(options);
420
101
  console.log("[Nuxt Users] Migration completed successfully!");
102
+ process.exit(0);
421
103
  } catch (error) {
422
104
  console.error("[Nuxt Users] Migration failed:", error);
423
105
  process.exit(1);
@@ -572,7 +254,7 @@ const main = defineCommand({
572
254
  meta: {
573
255
  name: "nuxt-users",
574
256
  description: "CLI for Nuxt Users Module - Manage users, migrations, and database operations",
575
- version: "1.1.0"
257
+ version: "1.1.3"
576
258
  },
577
259
  subCommands: {
578
260
  migrate,
package/dist/module.d.mts CHANGED
@@ -1,53 +1,5 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- type DatabaseType = 'sqlite' | 'mysql' | 'postgresql';
4
- type DatabaseConfig = {
5
- path?: string;
6
- host?: string;
7
- port?: number;
8
- user?: string;
9
- password?: string;
10
- database?: string;
11
- };
12
- interface ModuleOptions {
13
- connector?: {
14
- name: DatabaseType;
15
- options: DatabaseConfig;
16
- };
17
- tables: {
18
- migrations: string;
19
- users: string;
20
- personalAccessTokens: string;
21
- passwordResetTokens: string;
22
- };
23
- /**
24
- * Mailer configuration options for sending emails (e.g., password resets)
25
- * Uses nodemailer
26
- */
27
- mailer?: MailerOptions;
28
- /**
29
- * Base URL for password reset links
30
- * @default 'http://localhost:3000' // Example, will be set in module defaults
31
- */
32
- passwordResetBaseUrl?: string;
33
- /**
34
- * Skip database checks during module setup to prevent hanging
35
- * @default false
36
- */
37
- skipDatabaseChecks?: boolean;
38
- }
39
- interface MailerOptions {
40
- host: string;
41
- port: number;
42
- secure?: boolean;
43
- auth: {
44
- user: string;
45
- pass: string;
46
- };
47
- defaults?: {
48
- from: string;
49
- };
50
- }
2
+ import { M as ModuleOptions } from './shared/nuxt-users.Dtq4WcpY.mjs';
51
3
 
52
4
  declare const defaultOptions: ModuleOptions;
53
5
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
package/dist/module.d.ts CHANGED
@@ -1,53 +1,5 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- type DatabaseType = 'sqlite' | 'mysql' | 'postgresql';
4
- type DatabaseConfig = {
5
- path?: string;
6
- host?: string;
7
- port?: number;
8
- user?: string;
9
- password?: string;
10
- database?: string;
11
- };
12
- interface ModuleOptions {
13
- connector?: {
14
- name: DatabaseType;
15
- options: DatabaseConfig;
16
- };
17
- tables: {
18
- migrations: string;
19
- users: string;
20
- personalAccessTokens: string;
21
- passwordResetTokens: string;
22
- };
23
- /**
24
- * Mailer configuration options for sending emails (e.g., password resets)
25
- * Uses nodemailer
26
- */
27
- mailer?: MailerOptions;
28
- /**
29
- * Base URL for password reset links
30
- * @default 'http://localhost:3000' // Example, will be set in module defaults
31
- */
32
- passwordResetBaseUrl?: string;
33
- /**
34
- * Skip database checks during module setup to prevent hanging
35
- * @default false
36
- */
37
- skipDatabaseChecks?: boolean;
38
- }
39
- interface MailerOptions {
40
- host: string;
41
- port: number;
42
- secure?: boolean;
43
- auth: {
44
- user: string;
45
- pass: string;
46
- };
47
- defaults?: {
48
- from: string;
49
- };
50
- }
2
+ import { M as ModuleOptions } from './shared/nuxt-users.Dtq4WcpY.js';
51
3
 
52
4
  declare const defaultOptions: ModuleOptions;
53
5
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "nuxt-users",
3
3
  "configKey": "nuxtUsers",
4
- "version": "1.1.3",
4
+ "version": "1.1.4",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
7
- "unbuild": "2.0.0"
7
+ "unbuild": "3.6.0"
8
8
  }
9
9
  }
@@ -6,7 +6,7 @@ const formData = reactive({
6
6
  const message = ref("");
7
7
  const loading = ref(false);
8
8
  const isError = ref(false);
9
- const handleForgotPassword = async (data) => {
9
+ const handleForgotPassword = async () => {
10
10
  loading.value = true;
11
11
  message.value = "";
12
12
  isError.value = false;
@@ -17,8 +17,7 @@ const handleForgotPassword = async (data) => {
17
17
  "Content-Type": "application/json",
18
18
  "Accept": "application/json"
19
19
  },
20
- body: JSON.stringify({ email: data.email })
21
- // Use email from form data
20
+ body: JSON.stringify({ email: formData.email })
22
21
  });
23
22
  const responseData = await response.json();
24
23
  if (!response.ok) {
@@ -44,25 +43,24 @@ const handleForgotPassword = async (data) => {
44
43
  <template>
45
44
  <div>
46
45
  <h2>Forgot Password</h2>
47
- <FormKit
48
- v-slot="{ disabled }"
49
- type="form"
50
- :actions="false"
51
- @submit="handleForgotPassword"
52
- >
53
- <FormKit
54
- v-model="formData.email"
55
- type="email"
56
- name="email"
57
- label="Email"
58
- placeholder="your@email.com"
59
- validation="required|email"
60
- />
61
- <FormKit
46
+ <form @submit.prevent="handleForgotPassword">
47
+ <div class="form-group">
48
+ <label for="email">Email</label>
49
+ <input
50
+ id="email"
51
+ v-model="formData.email"
52
+ type="email"
53
+ name="email"
54
+ placeholder="your@email.com"
55
+ required
56
+ >
57
+ </div>
58
+ <button
62
59
  type="submit"
63
- :label="loading ? 'Sending...' : 'Send Password Reset Link'"
64
- :disabled="Boolean(disabled) || loading"
65
- />
60
+ :disabled="loading"
61
+ >
62
+ {{ loading ? "Sending..." : "Send Password Reset Link" }}
63
+ </button>
66
64
  <p
67
65
  v-if="message"
68
66
  :class="{ error: isError, success: !isError }"
@@ -70,10 +68,10 @@ const handleForgotPassword = async (data) => {
70
68
  >
71
69
  {{ message }}
72
70
  </p>
73
- </FormKit>
71
+ </form>
74
72
  </div>
75
73
  </template>
76
74
 
77
75
  <style scoped>
78
- .error{color:red}.success{color:green}.form-message{font-size:.9rem;margin-top:1em}:deep(.formkit-outer){margin-bottom:1em}:deep(.formkit-label){display:block;font-weight:700;margin-bottom:.25em}:deep(.formkit-input input[type=email]),:deep(.formkit-input input[type=password]){border:1px solid var(--color-border-dark);border-radius:4px;box-sizing:border-box;padding:.75em;width:100%}:deep(.formkit-input input[type=submit]){background-color:var(--color-gray-800);border:none;border-radius:4px;color:#fff;cursor:pointer;padding:.75em 1.5em}:deep(.formkit-input input[type=submit]:disabled){background-color:var(--color-gray-500);cursor:not-allowed}:deep(.formkit-messages){list-style:none;margin-top:.25em;padding:0}:deep(.formkit-message){color:red;font-size:.8rem}
76
+ .error{color:red}.success{color:green}.form-message{font-size:.9rem;margin-top:1em}.form-group{margin-bottom:1em}label{display:block;font-weight:700;margin-bottom:.25em}input[type=email]{border:1px solid var(--color-border-dark);border-radius:4px;box-sizing:border-box;padding:.75em;width:100%}button[type=submit]{background-color:var(--color-gray-800);border:none;border-radius:4px;color:#fff;cursor:pointer;padding:.75em 1.5em}button[type=submit]:disabled{background-color:var(--color-gray-500);cursor:not-allowed}
79
77
  </style>