diff --git a/config/environments/development.js b/config/environments/development.js index 6b94542..4a85377 100644 --- a/config/environments/development.js +++ b/config/environments/development.js @@ -7,6 +7,12 @@ module.exports = { dialect: 'mysql', }, + cache: { + enabled: false, + defaultDuration: '1 minute', + debug: true, + }, + session: { secret_token: process.env.SECRET_TOKEN || "B57J=7B`NQ$y98|~5;hc715bo09^5oz8NR+]n9r~215B91Nd9P%25_N6r!GHcOKp|18y5-73Dr5^@9k7n]5l<-41D1o", token_expires_in: '365d' diff --git a/config/environments/production.js b/config/environments/production.js index 695ebac..7cdbdd8 100644 --- a/config/environments/production.js +++ b/config/environments/production.js @@ -15,6 +15,13 @@ module.exports = { */ }, + cache: { + enabled: false, + defaultDuration: '1 minute', + debug: true, + }, + + session: { secret_token: process.env.SECRET_TOKEN || "B57J=7B`NQ$y98|~5;hc715bo09^5oz8NR+]n9r~215B91Nd9P%25_N6r!GHcOKp|18y5-73Dr5^@9k7n]5l<-41D1o", token_expires_in: '365d' diff --git a/middlewares/cache.js b/middlewares/cache.js index f0e42d0..950569c 100644 --- a/middlewares/cache.js +++ b/middlewares/cache.js @@ -1,12 +1,13 @@ const apicache = require('apicache'); const redis = require('redis'); -const NODE_ENV = process.env.NODE_ENV || 'development'; +const config = require('../config'); + const cacheWithRedis = apicache .options({ - debug: true, - defaultDuration: '1 minute', - enabled: NODE_ENV !== 'development', + debug: config.cache.debug, + defaultDuration: config.cache.defaultDuration, + enabled: config.cache.enabled, //redisClient: redis.createClient(), //appendKey: (req, res) => req.user ? req.user.id : '', });