meddelare-server
Advanced tools
Comparing version 1.4.2 to 1.5.0
@@ -177,3 +177,3 @@ "use strict"; | ||
cache.put(cacheKey, uncachedResult, self._options.LOCAL_CACHE_TIME_GOOD_RESULT); | ||
cache.put(cacheKey, uncachedResult, self._options.memoryCache.goodResultTimeout); | ||
}) | ||
@@ -183,9 +183,9 @@ .catch(function(err) { | ||
cache.put(cacheKey, self._options.DEFAULT_UNKNOWN_COUNT, self._options.LOCAL_CACHE_TIME_BAD_RESULT); | ||
cache.put(cacheKey, self._options.unknownCount, self._options.memoryCache.badResultTimeout); | ||
return self._options.DEFAULT_UNKNOWN_COUNT; | ||
return self._options.unknownCount; | ||
}); | ||
// Setting a cache timeout just in case, even though it can lead to parallel requests. | ||
cache.put(cacheKey, retrieveCountPromise, self._options.LOCAL_CACHE_TIME_TIMEOUT_RESULT); | ||
cache.put(cacheKey, retrieveCountPromise, self._options.memoryCache.timeoutResultTimeout); | ||
@@ -220,10 +220,12 @@ return retrieveCountPromise; | ||
// Cache results in memory -- but keep good and bad (error thrown) results for different periods of time. | ||
LOCAL_CACHE_TIME_GOOD_RESULT: 4 * 60 * 1000, | ||
LOCAL_CACHE_TIME_BAD_RESULT: 1 * 60 * 1000, | ||
LOCAL_CACHE_TIME_TIMEOUT_RESULT: 10 * 1000, | ||
memoryCache: { | ||
goodResultTimeout: 4 * 60 * 1000, | ||
badResultTimeout: 1 * 60 * 1000, | ||
timeoutResultTimeout: 10 * 1000, | ||
}, | ||
// Return this count if none was found or an error was thrown. | ||
DEFAULT_UNKNOWN_COUNT: -1, | ||
unknownCount: -1, | ||
}; | ||
module.exports = SocialButtonsCounts; |
@@ -31,6 +31,9 @@ "use strict"; | ||
this._SocialButtonsCounts = new SocialButtonsCounts({ | ||
logger: this._options.logger, | ||
}); | ||
// Pass options to SocialButtonsCounts. | ||
// Set logger separately instead of relying on the deep copy. | ||
options.socialButtonsCounts = options.socialButtonsCounts || {}; | ||
this._options.socialButtonsCounts.logger = this._options.socialButtonsCounts.logger || options.socialButtonsCounts.logger || this._options.logger; | ||
this._SocialButtonsCounts = new SocialButtonsCounts(this._options.socialButtonsCounts); | ||
return this; | ||
@@ -41,3 +44,3 @@ } | ||
// Setup caching headers (works well with cloudfront) | ||
res.set("Cache-Control", "max-age=" + this._options.CACHE_TIME); | ||
res.set("Cache-Control", "max-age=" + this._options.httpCacheTime); | ||
@@ -102,3 +105,3 @@ next(); | ||
// How many minutes should HTTP requests' results be cached. | ||
CACHE_TIME: process.env.CACHE_TIME || 4 * 60, | ||
httpCacheTime: 4 * 60, | ||
@@ -109,2 +112,4 @@ routerOptions: { | ||
}, | ||
socialButtonsCounts: {}, | ||
}; | ||
@@ -111,0 +116,0 @@ |
{ | ||
"name": "meddelare-server", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"description": "Install custom social share counters on your website with your own hosted solution, which only makes a single API request and loads minimal or zero assets to display the counters.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://meddelare.com/", |
@@ -8,3 +8,6 @@ var express = require("express"), | ||
SocialButtonsServerMiddleware = require("./lib/social-buttons-server-middleware.js"), | ||
socialButtonsServerMiddleware = new SocialButtonsServerMiddleware(), | ||
socialButtonsServerMiddlewareOptions = { | ||
httpCacheTime: process.env.CACHE_TIME, | ||
}, | ||
socialButtonsServerMiddleware = new SocialButtonsServerMiddleware(socialButtonsServerMiddlewareOptions), | ||
@@ -11,0 +14,0 @@ morgan = require("morgan"), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23207
307