Skip to content

Commit

Permalink
feat: added ioredis setup
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Sep 2, 2019
1 parent 7aef50c commit 46333c1
Show file tree
Hide file tree
Showing 3 changed files with 2,973 additions and 2,598 deletions.
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const fs = require('fs');

const Redis = require('ioredis');

const env = process.env.NODE_ENV || 'development';

let rateLimit = {
Expand All @@ -17,10 +19,14 @@ let rateLimit = {

if (env === 'development') rateLimit = false;

const redisClient = new Redis({
showFriendlyErrorStack: env === 'development'
});

function sharedConfig(prefix) {
prefix = prefix.toUpperCase();
const config = {
cabin: { axe: { capture: false } },
cabin: { capture: false },
protocol: process.env[`${prefix}_PROTOCOL`] || 'http',
ssl: {
key: process.env[`${prefix}_SSL_KEY_PATH`]
Expand Down Expand Up @@ -54,7 +60,11 @@ function sharedConfig(prefix) {
// these are hooks that can get run before/after configuration
// and must be functions that accept one argument `app`
hookBeforeSetup: false,
hookBeforeRoutes: false
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
};
return config;
}
Expand Down
54 changes: 27 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@
"contributors": [
"Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)"
],
"dependencies": {},
"dependencies": {
"ioredis": "^4.14.0"
},
"devDependencies": {
"@commitlint/cli": "^7.2.1",
"@commitlint/config-conventional": "^7.1.2",
"ava": "^1.0.1",
"codecov": "^3.1.0",
"cross-env": "^5.2.0",
"eslint": "^5.12.0",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"ava": "^2.3.0",
"codecov": "^3.5.0",
"cross-env": "^5.2.1",
"eslint": "^6.3.0",
"eslint-config-xo-lass": "^1.0.3",
"fixpack": "^2.3.1",
"husky": "^1.3.1",
"lint-staged": "^8.1.0",
"nyc": "^13.1.0",
"remark-cli": "^6.0.1",
"remark-preset-github": "^0.0.13",
"xo": "^0.23.0"
"husky": "^3.0.5",
"lint-staged": "^9.2.5",
"nyc": "^14.1.1",
"remark-cli": "^7.0.0",
"remark-preset-github": "^0.0.16",
"xo": "^0.24.0"
},
"engines": {
"node": ">=8.3"
Expand All @@ -55,20 +57,18 @@
],
"license": "MIT",
"lint-staged": {
"linters": {
"*.js": [
"xo --fix",
"git add"
],
"*.md": [
"remark . -qfo",
"git add"
],
"package.json": [
"fixpack",
"git add"
]
}
"*.js": [
"xo --fix",
"git add"
],
"*.md": [
"remark . -qfo",
"git add"
],
"package.json": [
"fixpack",
"git add"
]
},
"main": "index.js",
"prettier": {
Expand Down
Loading

0 comments on commit 46333c1

Please sign in to comment.