@ladjs/shared-config
Advanced tools
+26
-24
| const fs = require('fs'); | ||
| const Redis = require('ioredis'); | ||
| const Redis = require('@ladjs/redis'); | ||
| const env = process.env.NODE_ENV || 'development'; | ||
| const isDev = env === 'development'; | ||
| let rateLimit = { | ||
| duration: process.env.RATELIMIT_DURATION | ||
| ? parseInt(process.env.RATELIMIT_DURATION, 10) | ||
| : 60000, | ||
| max: process.env.RATELIMIT_MAX | ||
| ? parseInt(process.env.RATELIMIT_MAX, 10) | ||
| : 100, | ||
| id: ctx => ctx.ip, | ||
| prefix: process.env.RATELIMIT_PREFIX | ||
| ? process.env.RATELIMIT_PREFIX | ||
| : `limit_${env.toLowerCase()}` | ||
| }; | ||
| const rateLimit = isDev | ||
| ? false | ||
| : { | ||
| duration: process.env.RATELIMIT_DURATION | ||
| ? parseInt(process.env.RATELIMIT_DURATION, 10) | ||
| : 60000, | ||
| max: process.env.RATELIMIT_MAX | ||
| ? parseInt(process.env.RATELIMIT_MAX, 10) | ||
| : 100, | ||
| id: ctx => ctx.ip, | ||
| prefix: process.env.RATELIMIT_PREFIX | ||
| ? process.env.RATELIMIT_PREFIX | ||
| : `limit_${env.toLowerCase()}` | ||
| }; | ||
| if (env === 'development') rateLimit = false; | ||
| const redisClient = new Redis({ | ||
| showFriendlyErrorStack: env === 'development' | ||
| }); | ||
| function sharedConfig(prefix) { | ||
@@ -64,9 +61,14 @@ prefix = prefix.toUpperCase(); | ||
| hookBeforeRoutes: false, | ||
| // <https://github.com/luin/ioredis> | ||
| // this is used for rate limiting and session storage (e.g. passport) | ||
| // we support ioredis which allows clustering, sentinels, etc | ||
| redisClient, | ||
| // <https://github.com/ladjs/store-ip-address> | ||
| storeIPAddress: {} | ||
| storeIPAddress: {}, | ||
| // ioredis configuration object | ||
| // <https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options> | ||
| redis: { | ||
| showFriendlyErrorStack: isDev | ||
| } | ||
| }; | ||
| // <https://github.com/luin/ioredis> | ||
| // this is used for rate limiting and session storage (e.g. passport) | ||
| // we support ioredis which allows clustering, sentinels, etc | ||
| config.redisClient = new Redis(config.redis, config.logger, isDev); | ||
| return config; | ||
@@ -73,0 +75,0 @@ } |
+2
-2
| { | ||
| "name": "@ladjs/shared-config", | ||
| "description": "Shared configuration for Lad's API and Web servers", | ||
| "version": "0.0.4", | ||
| "version": "0.0.5", | ||
| "author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
@@ -23,3 +23,3 @@ "ava": { | ||
| "dependencies": { | ||
| "ioredis": "^4.14.0" | ||
| "@ladjs/redis": "^1.0.0" | ||
| }, | ||
@@ -26,0 +26,0 @@ "devDependencies": { |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
7893
2.68%76
5.56%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed