@ladjs/shared-config
Advanced tools
+18
-1
| const fs = require('fs'); | ||
| const process = require('process'); | ||
| const util = require('util'); | ||
| const dayjs = require('dayjs-with-plugins'); | ||
| const isSANB = require('is-string-and-not-blank'); | ||
| const { boolean } = require('boolean'); | ||
| const RATE_LIMIT_EXCEEDED = 'Rate limit exceeded, retry in %s.'; | ||
| const TIMEOUT_MESSAGE = | ||
@@ -50,2 +54,15 @@ 'Your request has timed out and we have been alerted of this issue. Please try again or contact us.'; | ||
| : { | ||
| errorMessage(exp, ctx) { | ||
| const fn = | ||
| typeof ctx.request.t === 'function' | ||
| ? ctx.request.t | ||
| : util.format; | ||
| return fn( | ||
| RATE_LIMIT_EXCEEDED, | ||
| dayjs() | ||
| .add(exp, 'ms') | ||
| .locale(ctx.state.locale || 'en') | ||
| .fromNow(true) | ||
| ); | ||
| }, | ||
| duration: process.env[`${prefix}_RATELIMIT_DURATION`] | ||
@@ -56,3 +73,3 @@ ? Number.parseInt(process.env[`${prefix}_RATELIMIT_DURATION`], 10) | ||
| ? Number.parseInt(process.env[`${prefix}_RATELIMIT_MAX`], 10) | ||
| : 100, | ||
| : 1000, | ||
| id: (ctx) => ctx.ip, | ||
@@ -59,0 +76,0 @@ prefix: process.env[`${prefix}_RATELIMIT_PREFIX`] |
+8
-47
| { | ||
| "name": "@ladjs/shared-config", | ||
| "description": "Shared configuration for Lad's API and Web servers", | ||
| "version": "7.0.3", | ||
| "version": "8.0.0", | ||
| "author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
| "ava": { | ||
| "serial": true, | ||
| "failFast": true, | ||
| "verbose": true | ||
| }, | ||
| "bugs": { | ||
@@ -15,7 +10,2 @@ "url": "https://github.com/ladjs/shared-config/issues", | ||
| }, | ||
| "commitlint": { | ||
| "extends": [ | ||
| "@commitlint/config-conventional" | ||
| ] | ||
| }, | ||
| "contributors": [ | ||
@@ -26,2 +16,4 @@ "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)" | ||
| "boolean": "^3.2.0", | ||
| "dayjs": "^1.11.3", | ||
| "dayjs-with-plugins": "^1.0.2", | ||
| "is-string-and-not-blank": "^0.0.2" | ||
@@ -33,3 +25,2 @@ }, | ||
| "ava": "^4.2.0", | ||
| "codecov": "^3.8.2", | ||
| "cross-env": "^7.0.3", | ||
@@ -47,3 +38,3 @@ "eslint": "^8.16.0", | ||
| "engines": { | ||
| "node": ">=8.3" | ||
| "node": ">=14" | ||
| }, | ||
@@ -62,27 +53,6 @@ "files": [ | ||
| "license": "MIT", | ||
| "lint-staged": { | ||
| "*.js": [ | ||
| "xo --fix" | ||
| ], | ||
| "*.md": [ | ||
| "remark . -qfo" | ||
| ], | ||
| "package.json": [ | ||
| "fixpack" | ||
| ] | ||
| }, | ||
| "main": "index.js", | ||
| "prettier": { | ||
| "singleQuote": true, | ||
| "bracketSpacing": true, | ||
| "trailingComma": "none" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "remarkConfig": { | ||
| "plugins": [ | ||
| "preset-github" | ||
| ] | ||
| }, | ||
| "repository": { | ||
@@ -93,16 +63,7 @@ "type": "git", | ||
| "scripts": { | ||
| "ava": "cross-env NODE_ENV=test ava", | ||
| "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||
| "lint": "xo && remark . -qfo", | ||
| "nyc": "cross-env NODE_ENV=test nyc ava", | ||
| "test": "npm run lint && npm run ava", | ||
| "test-coverage": "npm run lint && npm run nyc" | ||
| }, | ||
| "xo": { | ||
| "prettier": true, | ||
| "space": true, | ||
| "extends": [ | ||
| "xo-lass" | ||
| ] | ||
| "lint": "xo --fix && remark . -qfo && fixpack", | ||
| "prepare": "husky install", | ||
| "pretest": "npm run lint", | ||
| "test": "cross-env NODE_ENV=test nyc ava" | ||
| } | ||
| } |
+1
-10
| # [**@ladjs/shared-config**](https://github.com/ladjs/shared-config) | ||
| [](https://travis-ci.com/ladjs/shared-config) | ||
| [](https://codecov.io/gh/ladjs/shared-config) | ||
| [](https://github.com/ladjs/shared-config/actions/workflows/ci.yml) | ||
| [](https://github.com/sindresorhus/xo) | ||
@@ -30,9 +29,3 @@ [](https://github.com/prettier/prettier) | ||
| [yarn][]: | ||
| ```sh | ||
| yarn add @ladjs/shared-config | ||
| ``` | ||
| ## Usage | ||
@@ -61,3 +54,1 @@ | ||
| [npm]: https://www.npmjs.com/ | ||
| [yarn]: https://yarnpkg.com/ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 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 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
13
-7.14%157
11.35%10295
-2.71%4
100%53
-14.52%+ Added
+ Added
+ Added
+ Added