@onlineapps/conn-base-cache 1.0.1 → 1.0.2

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/API.md CHANGED
File without changes
package/README.md CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@onlineapps/conn-base-cache",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Redis cache connector with TTL, invalidation, and namespace support for OA Drive microservices",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
7
  "test": "jest",
8
- "test:unit": "jest test/unit",
9
- "test:integration": "jest test/integration",
8
+ "test:unit": "jest tests/unit",
9
+ "test:integration": "jest tests/integration",
10
10
  "test:watch": "jest --watch",
11
11
  "docs": "jsdoc2md --files src/**/*.js > API.md"
12
12
  },
package/src/index.js CHANGED
@@ -68,10 +68,21 @@ class CacheConnector {
68
68
  * });
69
69
  */
70
70
  constructor(config = {}) {
71
+ // Host and port are REQUIRED - no fallbacks (fail-fast principle)
72
+ const host = config.host || process.env.REDIS_HOST;
73
+ const port = config.port || process.env.REDIS_PORT;
74
+
75
+ if (!host) {
76
+ throw new Error('[CacheConnector] Missing required config: host (set REDIS_HOST env or pass config.host)');
77
+ }
78
+ if (!port) {
79
+ throw new Error('[CacheConnector] Missing required config: port (set REDIS_PORT env or pass config.port)');
80
+ }
81
+
71
82
  // Configuration
72
83
  this.config = {
73
- host: config.host || process.env.REDIS_HOST || 'localhost',
74
- port: config.port || process.env.REDIS_PORT || 6379,
84
+ host,
85
+ port: parseInt(port, 10),
75
86
  password: config.password || process.env.REDIS_PASSWORD,
76
87
  db: config.db || process.env.REDIS_DB || 0,
77
88
  keyPrefix: 'cache:', // ALWAYS use cache: prefix
@@ -109,7 +109,7 @@ class RedisSimulator {
109
109
  }
110
110
  }
111
111
 
112
- describe('CacheConnector - Component Tests', () => {
112
+ describe('CacheConnector - Component Tests @component', () => {
113
113
  let cacheConnector;
114
114
  let redisSimulator;
115
115
 
@@ -11,7 +11,7 @@ const SKIP_INTEGRATION = process.env.SKIP_INTEGRATION === 'true';
11
11
  const REDIS_HOST = process.env.REDIS_HOST || 'localhost';
12
12
  const REDIS_PORT = process.env.REDIS_PORT || 6379;
13
13
 
14
- describe('CacheConnector - Integration Tests', () => {
14
+ describe('CacheConnector - Integration Tests @integration', () => {
15
15
  if (SKIP_INTEGRATION) {
16
16
  it.skip('Skipping integration tests (SKIP_INTEGRATION=true)', () => {});
17
17
  return;
@@ -9,7 +9,7 @@ jest.mock('ioredis');
9
9
  const Redis = require('ioredis');
10
10
  const CacheConnector = require('../../src/index');
11
11
 
12
- describe('CacheConnector - Edge Cases & Full Coverage', () => {
12
+ describe('CacheConnector - Edge Cases & Full Coverage @unit', () => {
13
13
  let cacheConnector;
14
14
  let mockRedisClient;
15
15
 
@@ -9,7 +9,7 @@ jest.mock('ioredis');
9
9
  const Redis = require('ioredis');
10
10
  const CacheConnector = require('../../src/index');
11
11
 
12
- describe('CacheConnector - Unit Tests', () => {
12
+ describe('CacheConnector - Unit Tests @unit', () => {
13
13
  let cacheConnector;
14
14
  let mockRedisClient;
15
15