nuxt-users 1.47.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.47.0",
7
+ "version": "1.48.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -195,6 +195,11 @@ const module$1 = defineNuxtModule({
195
195
  method: "post",
196
196
  handler: resolver.resolve("./runtime/server/api/nuxt-users/index.post")
197
197
  });
198
+ addServerHandler({
199
+ route: `${base}/inactive`,
200
+ method: "get",
201
+ handler: resolver.resolve("./runtime/server/api/nuxt-users/inactive.get")
202
+ });
198
203
  addServerHandler({
199
204
  route: `${base}/:id`,
200
205
  method: "get",
@@ -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.47.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",
@@ -34,9 +34,6 @@
34
34
  },
35
35
  "license": "MIT",
36
36
  "type": "module",
37
- "resolutions": {
38
- "@nuxt/kit": "4.3.1"
39
- },
40
37
  "exports": {
41
38
  ".": {
42
39
  "types": "./dist/types.d.mts",
@@ -68,8 +65,11 @@
68
65
  "check:translations": "tsx scripts/check-translations.ts",
69
66
  "check:locale-consistency": "tsx scripts/check-locale-consistency.ts",
70
67
  "check:npm_token": "dotenv -- sh -c 'if [ -z \"$NPM_TOKEN\" ]; then echo \"❌ NPM_TOKEN environment variable is not set in .env file. Please set it to your npm token.\"; exit 1; fi'",
68
+ "check:npm_auth": "dotenv -- sh -c 'npm whoami --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=$NPM_TOKEN'",
69
+ "release:publish:dry": "dotenv -- sh -c 'npm publish --dry-run --ignore-scripts --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=$NPM_TOKEN'",
70
+ "release:preflight": "yarn prerelease && yarn check:npm_token && yarn check:npm_auth && sh scripts/release-preflight.sh",
71
71
  "prerelease": "node -v | grep -q 'v22' || (echo 'Please use Node.js v22 for deployment' && exit 1)",
72
- "release": "yarn check:npm_token && yarn lint && yarn check:translations && yarn check:locale-consistency && yarn test && yarn prepack && dotenv -- changelogen --release && dotenv -- sh -c 'npm publish --//registry.npmjs.org/:_authToken=$NPM_TOKEN --registry https://registry.npmjs.org/' && git push --follow-tags",
72
+ "release": "yarn release:preflight && yarn lint && yarn check:translations && yarn check:locale-consistency && yarn test && yarn prepack && yarn release:publish:dry && dotenv -- changelogen --release && dotenv -- sh -c 'npm publish --//registry.npmjs.org/:_authToken=$NPM_TOKEN --registry https://registry.npmjs.org/' && git push --follow-tags",
73
73
  "lint": "eslint .",
74
74
  "lint:fix": "eslint . --fix",
75
75
  "pretest": "node -v | grep -q 'v22' || (echo 'Please use Node.js v22 for testing' && exit 1)",
@@ -114,7 +114,7 @@
114
114
  "@nuxt/kit": "^3.17.6 || ^4.0.0",
115
115
  "bcrypt": "^6.0.0",
116
116
  "nodemailer": "^7.0.5",
117
- "nuxt-api-shield": "^0.8.0 || ^0.10.0"
117
+ "nuxt-api-shield": "^1.0.0"
118
118
  },
119
119
  "peerDependenciesMeta": {
120
120
  "nuxt-api-shield": {
@@ -132,12 +132,12 @@
132
132
  "@nuxt/vite-builder": "^4.2.0",
133
133
  "@types/bcrypt": "^6.0.0",
134
134
  "@types/node": "^25.0.3",
135
- "@types/nodemailer": "^6.4.17",
135
+ "@types/nodemailer": "^8.0.0",
136
136
  "@types/pg": "^8.15.4",
137
137
  "changelogen": "^0.6.2",
138
138
  "dotenv-cli": "^11.0.0",
139
139
  "eslint": "^9.30.1",
140
- "nuxt": "4.3.1",
140
+ "nuxt": "^3.17.6",
141
141
  "tsx": "^4.20.3",
142
142
  "typescript": "~5.9.0",
143
143
  "unbuild": "^3.0.0",
@@ -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
 
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env sh
2
+ set -e
3
+
4
+ if [ "$(git branch --show-current)" != "main" ]; then
5
+ echo "❌ Release must run on branch main (current: $(git branch --show-current))"
6
+ exit 1
7
+ fi
8
+
9
+ if [ -n "$(git status --porcelain)" ]; then
10
+ echo "❌ Working tree is not clean. Commit or stash before release."
11
+ exit 1
12
+ fi
13
+
14
+ git fetch origin
15
+
16
+ behind="$(git rev-list HEAD..origin/main --count 2>/dev/null || echo 0)"
17
+ if [ "$behind" -ne 0 ]; then
18
+ echo "❌ main is $behind commit(s) behind origin/main. Run: git pull --rebase origin main"
19
+ exit 1
20
+ fi
21
+
22
+ echo "✓ Git: branch main, clean, synced with origin/main"