nuxt-users 1.48.0 → 1.48.1

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/dist/cli.mjs CHANGED
@@ -392,7 +392,7 @@ const projectInfo = defineCommand({
392
392
  console.log("[Nuxt Users] Migrations:", nuxtUsersConfig.tables?.migrations);
393
393
  console.log();
394
394
  try {
395
- const migrationsTableExists = await checkTableExists(nuxtUsersConfig, "migrations");
395
+ const migrationsTableExists = await checkTableExists(nuxtUsersConfig, nuxtUsersConfig.tables?.migrations || "migrations");
396
396
  console.log("[Nuxt Users] \u{1F4CA} Migration Status:");
397
397
  if (migrationsTableExists) {
398
398
  const appliedMigrations = await getAppliedMigrations(nuxtUsersConfig);
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "1.48.0",
7
+ "version": "1.48.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -2,7 +2,7 @@ import { useDb } from "./db.js";
2
2
  export const createMigrationsTable = async (options) => {
3
3
  const connectorName = options.connector.name;
4
4
  const db = await useDb(options);
5
- const tableName = "migrations";
5
+ const tableName = options.tables.migrations;
6
6
  console.log(`[Nuxt Users] DB:Create Migrations ${connectorName} Table Creating ${tableName} table with ${connectorName} connector...`);
7
7
  if (connectorName === "sqlite") {
8
8
  await db.sql`
@@ -1,6 +1,6 @@
1
1
  import type { Database } from 'db0';
2
2
  import type { ModuleOptions } from 'nuxt-users/utils';
3
3
  export declare const closeAllDbConnections: () => Promise<void>;
4
- export declare const getConnector: (name: string) => Promise<typeof import("db0/connectors/mysql2").default | typeof import("db0/connectors/postgresql").default | typeof import("db0/connectors/better-sqlite3").default>;
4
+ export declare const getConnector: (name: string) => Promise<typeof import("./mysql-connector.js").default | typeof import("db0/connectors/postgresql").default | typeof import("db0/connectors/better-sqlite3").default>;
5
5
  export declare const useDb: (options: ModuleOptions) => Promise<Database>;
6
6
  export declare const checkTableExists: (options: ModuleOptions, tableName: string) => Promise<boolean>;
@@ -3,8 +3,8 @@ import { isBuildTime } from "./build-time.js";
3
3
  const dbCache = /* @__PURE__ */ new Map();
4
4
  export const closeAllDbConnections = async () => {
5
5
  for (const db of dbCache.values()) {
6
- if (db && typeof db.disconnect === "function") {
7
- await db.disconnect();
6
+ if (db && typeof db.dispose === "function") {
7
+ await db.dispose();
8
8
  }
9
9
  }
10
10
  dbCache.clear();
@@ -13,7 +13,7 @@ export const getConnector = async (name) => {
13
13
  try {
14
14
  switch (name) {
15
15
  case "mysql":
16
- return (await import("db0/connectors/mysql2")).default;
16
+ return (await import("./mysql-connector.js")).default;
17
17
  case "postgresql":
18
18
  return (await import("db0/connectors/postgresql")).default;
19
19
  case "sqlite":
@@ -43,7 +43,7 @@ export const migrations = [
43
43
  export const getAppliedMigrations = async (options) => {
44
44
  const db = await useDb(options);
45
45
  try {
46
- const result = await db.sql`SELECT name FROM migrations ORDER BY id`;
46
+ const result = await db.sql`SELECT name FROM {${options.tables.migrations}} ORDER BY id`;
47
47
  return result.rows.map((row) => row.name);
48
48
  } catch {
49
49
  return [];
@@ -51,7 +51,7 @@ export const getAppliedMigrations = async (options) => {
51
51
  };
52
52
  export const markMigrationAsApplied = async (options, migrationName) => {
53
53
  const db = await useDb(options);
54
- await db.sql`INSERT INTO migrations (name) VALUES (${migrationName})`;
54
+ await db.sql`INSERT INTO {${options.tables.migrations}} (name) VALUES (${migrationName})`;
55
55
  };
56
56
  export const runMigrations = async (options) => {
57
57
  console.log("[Nuxt Users] Starting migration system...");
@@ -0,0 +1,47 @@
1
+ import type { Pool, PoolOptions } from 'mysql2/promise';
2
+ interface ConnectorOptions extends PoolOptions {
3
+ host?: string;
4
+ port?: number;
5
+ user?: string;
6
+ password?: string;
7
+ database?: string;
8
+ }
9
+ interface RawStatement {
10
+ all(...args: unknown[]): Promise<unknown[]>;
11
+ run(...args: unknown[]): Promise<{
12
+ success: boolean;
13
+ }>;
14
+ get(...args: unknown[]): Promise<unknown>;
15
+ }
16
+ declare class BoundableStatement {
17
+ _statement: RawStatement | null;
18
+ constructor(rawStmt: RawStatement | null);
19
+ bind(...params: unknown[]): BoundStatement;
20
+ }
21
+ declare class BoundStatement {
22
+ #private;
23
+ constructor(statement: BoundableStatement, params: unknown[]);
24
+ bind(...params: unknown[]): BoundStatement;
25
+ all(): Promise<unknown[]>;
26
+ run(): Promise<{
27
+ success: boolean;
28
+ }>;
29
+ get(): Promise<unknown>;
30
+ }
31
+ type QueryFn = (sql: string, params?: unknown[]) => Promise<any>;
32
+ declare class StatementWrapper extends BoundableStatement {
33
+ #private;
34
+ constructor(sql: string, query: QueryFn);
35
+ all(...params: unknown[]): Promise<any>;
36
+ run(...params: unknown[]): Promise<any>;
37
+ get(...params: unknown[]): Promise<any>;
38
+ }
39
+ export default function mysqlPoolConnector(opts: ConnectorOptions): {
40
+ name: string;
41
+ dialect: "mysql";
42
+ getInstance: () => Promise<Pool>;
43
+ exec: (sql: string) => Promise<any>;
44
+ prepare: (sql: string) => StatementWrapper;
45
+ dispose: () => Promise<void>;
46
+ };
47
+ export {};
@@ -0,0 +1,85 @@
1
+ class BoundableStatement {
2
+ _statement;
3
+ constructor(rawStmt) {
4
+ this._statement = rawStmt;
5
+ }
6
+ bind(...params) {
7
+ return new BoundStatement(this, params);
8
+ }
9
+ }
10
+ class BoundStatement {
11
+ #statement;
12
+ #params;
13
+ constructor(statement, params) {
14
+ this.#statement = statement;
15
+ this.#params = params;
16
+ }
17
+ bind(...params) {
18
+ return new BoundStatement(this.#statement, params);
19
+ }
20
+ all() {
21
+ return this.#statement._statement.all(...this.#params);
22
+ }
23
+ run() {
24
+ return this.#statement._statement.run(...this.#params);
25
+ }
26
+ get() {
27
+ return this.#statement._statement.get(...this.#params);
28
+ }
29
+ }
30
+ class StatementWrapper extends BoundableStatement {
31
+ #query;
32
+ #sql;
33
+ constructor(sql, query) {
34
+ super(null);
35
+ this.#sql = sql;
36
+ this.#query = query;
37
+ }
38
+ async all(...params) {
39
+ return await this.#query(this.#sql, params);
40
+ }
41
+ async run(...params) {
42
+ const res = await this.#query(this.#sql, params);
43
+ return { success: true, ...res };
44
+ }
45
+ async get(...params) {
46
+ const res = await this.#query(this.#sql, params);
47
+ return res[0];
48
+ }
49
+ }
50
+ export default function mysqlPoolConnector(opts) {
51
+ let _pool = null;
52
+ const getPool = async () => {
53
+ if (_pool) return _pool;
54
+ const { createPool } = await import("mysql2/promise");
55
+ _pool = createPool({
56
+ ...opts,
57
+ enableKeepAlive: true,
58
+ keepAliveInitialDelay: 1e4,
59
+ maxIdle: 5,
60
+ idleTimeout: 6e4,
61
+ waitForConnections: true,
62
+ connectionLimit: 10,
63
+ queueLimit: 0
64
+ });
65
+ return _pool;
66
+ };
67
+ const query = async (sql, params) => {
68
+ const pool = await getPool();
69
+ const [rows] = await pool.query(sql, params);
70
+ return rows;
71
+ };
72
+ return {
73
+ name: "mysql",
74
+ dialect: "mysql",
75
+ getInstance: getPool,
76
+ exec: (sql) => query(sql),
77
+ prepare: (sql) => new StatementWrapper(sql, query),
78
+ dispose: async () => {
79
+ if (_pool) {
80
+ await _pool.end();
81
+ _pool = null;
82
+ }
83
+ }
84
+ };
85
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-users",
3
- "version": "1.48.0",
3
+ "version": "1.48.1",
4
4
  "description": "A comprehensive user management module for Nuxt 3 and Nuxt 4 applications with authentication, authorization, database support, and CLI tools",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -1,8 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # Configuration
4
- SERVER_HOST="34.159.83.210"
5
- SERVER_USER="sravanam"
4
+ SERVER_HOST="sravanam"
6
5
  REMOTE_DOCS_PATH="/var/www/nuxt-users.webmania.cc"
7
6
  LOCAL_BUILD_PATH="docs/.vitepress/dist"
8
7
 
@@ -28,7 +27,7 @@ tar -czf "$TEMP_TAR" -C "$LOCAL_BUILD_PATH" .
28
27
 
29
28
  # Upload and deploy
30
29
  echo -e "${YELLOW}📤 Uploading to $SERVER_HOST...${NC}"
31
- ssh "$SERVER_USER@$SERVER_HOST" << EOF
30
+ ssh "$SERVER_HOST" << EOF
32
31
  # Create backup of current docs
33
32
  if [ -d "$REMOTE_DOCS_PATH" ]; then
34
33
  echo "📋 Creating backup of current documentation..."
@@ -45,10 +44,10 @@ ssh "$SERVER_USER@$SERVER_HOST" << EOF
45
44
  EOF
46
45
 
47
46
  # Copy the tar file to server
48
- scp "$TEMP_TAR" "$SERVER_USER@$SERVER_HOST:/tmp/"
47
+ scp "$TEMP_TAR" "$SERVER_HOST:/tmp/"
49
48
 
50
49
  # Extract and deploy on server
51
- ssh "$SERVER_USER@$SERVER_HOST" << EOF
50
+ ssh "$SERVER_HOST" << EOF
52
51
  echo "📦 Extracting documentation..."
53
52
  tar -xzf "/tmp/$TEMP_TAR" -C "$REMOTE_DOCS_PATH"
54
53