@k03mad/request 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,10 +15,11 @@ const debug = _debug('mad:request');
15
15
  const prepareRequestOpts = (opts = {}) => {
16
16
  const UA = 'curl/8.1.2';
17
17
 
18
- const preparedOpts = {
19
- timeout: {request: 15_000},
20
- ...opts,
21
- };
18
+ const preparedOpts = {...opts};
19
+
20
+ if (!preparedOpts.timeout) {
21
+ preparedOpts.timeout = {request: 10_000};
22
+ }
22
23
 
23
24
  if (!preparedOpts.headers) {
24
25
  preparedOpts.headers = {'user-agent': UA};
@@ -105,7 +106,7 @@ export const requestCache = (url, opts = {}, {cacheBy, expire = 43_200} = {}) =>
105
106
  const {cachedResponse, date} = cache.get(cacheKey);
106
107
 
107
108
  const measurement = 'seconds';
108
- const currentDiff = (Date.now() - date) * 1000;
109
+ const currentDiff = Math.round((Date.now() - date) / 1000);
109
110
 
110
111
  if (currentDiff < expire) {
111
112
  debug(`${green('FROM CACHE')} :: ${currentDiff}/${expire} ${measurement} left :: ${log}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k03mad/request",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Request library",
5
5
  "maintainers": [
6
6
  "Kirill Molchanov <k03.mad@gmail.com"