@nest-boot/graphql-rate-limit 7.0.4 → 7.2.0

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.
@@ -0,0 +1,16 @@
1
+ import { RedisOptions } from "ioredis";
2
+ /**
3
+ * Loads Redis connection configuration from environment variables.
4
+ *
5
+ * Supports the following environment variables:
6
+ * - `REDIS_URL`: Full Redis connection URL (takes precedence over individual settings)
7
+ * - `REDIS_HOST`: Redis server hostname
8
+ * - `REDIS_PORT`: Redis server port
9
+ * - `REDIS_DB` or `REDIS_DATABASE`: Redis database number
10
+ * - `REDIS_USER` or `REDIS_USERNAME`: Redis username
11
+ * - `REDIS_PASS` or `REDIS_PASSWORD`: Redis password
12
+ * - `REDIS_TLS`: Enable TLS connection (any truthy value)
13
+ *
14
+ * @returns Redis connection options parsed from environment variables
15
+ */
16
+ export declare function loadConfigFromEnv(): RedisOptions;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadConfigFromEnv = loadConfigFromEnv;
4
+ /**
5
+ * Loads Redis connection configuration from environment variables.
6
+ *
7
+ * Supports the following environment variables:
8
+ * - `REDIS_URL`: Full Redis connection URL (takes precedence over individual settings)
9
+ * - `REDIS_HOST`: Redis server hostname
10
+ * - `REDIS_PORT`: Redis server port
11
+ * - `REDIS_DB` or `REDIS_DATABASE`: Redis database number
12
+ * - `REDIS_USER` or `REDIS_USERNAME`: Redis username
13
+ * - `REDIS_PASS` or `REDIS_PASSWORD`: Redis password
14
+ * - `REDIS_TLS`: Enable TLS connection (any truthy value)
15
+ *
16
+ * @returns Redis connection options parsed from environment variables
17
+ */
18
+ function loadConfigFromEnv() {
19
+ if (process.env.REDIS_URL) {
20
+ const url = new URL(process.env.REDIS_URL);
21
+ const port = url.port;
22
+ const database = url.pathname.split("/")[1];
23
+ return {
24
+ host: url.hostname,
25
+ port: port ? +port : undefined,
26
+ db: database ? +database : undefined,
27
+ username: url.username,
28
+ password: url.password,
29
+ ...(url.protocol === "rediss:" ? { tls: {} } : {}),
30
+ };
31
+ }
32
+ const host = process.env.REDIS_HOST;
33
+ const port = process.env.REDIS_PORT;
34
+ const database = process.env.REDIS_DB ?? process.env.REDIS_DATABASE;
35
+ const username = process.env.REDIS_USER ?? process.env.REDIS_USERNAME;
36
+ const password = process.env.REDIS_PASS ?? process.env.REDIS_PASSWORD;
37
+ const tls = !!process.env.REDIS_TLS;
38
+ return {
39
+ ...(host ? { host } : {}),
40
+ ...(port ? { port: +port } : {}),
41
+ ...(database ? { db: +database } : {}),
42
+ ...(username ? { username } : {}),
43
+ ...(password ? { password } : {}),
44
+ ...(tls ? { tls: {} } : {}),
45
+ };
46
+ }
47
+ //# sourceMappingURL=load-config-from-env.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-config-from-env.util.js","sourceRoot":"","sources":["../../src/utils/load-config-from-env.util.ts"],"names":[],"mappings":";;AAgBA,8CA+BC;AA7CD;;;;;;;;;;;;;GAaG;AACH,SAAgB,iBAAiB;IAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5C,OAAO;YACL,IAAI,EAAE,GAAG,CAAC,QAAQ;YAClB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YAC9B,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YACpC,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ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AC,EAAE,CAAC;KAC5B,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-boot/graphql-rate-limit",
3
- "version": "7.0.4",
3
+ "version": "7.2.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/nest-boot/nest-boot.git",
@@ -31,8 +31,8 @@
31
31
  "@nestjs/testing": "^11.1.11",
32
32
  "@types/express": "^5.0.3",
33
33
  "@types/jest": "^29.5.14",
34
- "@types/node": "^22.18.6",
35
- "eslint": "^9.39.2",
34
+ "@types/node": "^24.12.4",
35
+ "eslint": "^9.39.3",
36
36
  "express": "^5.1.0",
37
37
  "graphql": "^16.11.0",
38
38
  "graphql-query-complexity": "^1.1.0",
@@ -42,16 +42,14 @@
42
42
  "rxjs": "^7.8.2",
43
43
  "ts-jest": "^29.4.4",
44
44
  "typescript": "^5.9.3",
45
- "@nest-boot/eslint-config": "^7.0.3",
46
- "@nest-boot/eslint-plugin": "^7.0.5",
47
- "@nest-boot/graphql": "^7.1.3",
48
- "@nest-boot/tsconfig": "^7.0.1",
49
- "@nest-boot/redis": "^7.0.3"
45
+ "@nest-boot/eslint-config": "^7.1.0",
46
+ "@nest-boot/eslint-plugin": "^7.0.8",
47
+ "@nest-boot/graphql": "^7.1.5",
48
+ "@nest-boot/tsconfig": "^7.1.0"
50
49
  },
51
50
  "peerDependencies": {
52
51
  "@apollo/server": "^5.0.0",
53
52
  "@nest-boot/graphql": "^7.0.0",
54
- "@nest-boot/redis": "^7.0.0",
55
53
  "@nestjs/apollo": "^12.0.0",
56
54
  "@nestjs/common": "^11.0.0",
57
55
  "@nestjs/core": "^11.0.0",
@@ -77,9 +75,10 @@
77
75
  },
78
76
  "scripts": {
79
77
  "build": "tsc -p tsconfig.build.json",
80
- "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
78
+ "clean": "rm -rf .nx && rm -rf node_modules && rm -rf dist",
81
79
  "dev": "tsc -w -p tsconfig.build.json",
82
- "lint": "eslint \"{src,test}/**/*.ts\" --fix",
80
+ "lint": "eslint \"{src,test}/**/*.ts\"",
81
+ "lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
83
82
  "test": "jest",
84
83
  "test:cov": "jest --coverage",
85
84
  "test:watch": "jest --watch",