stubborn-ws
Advanced tools
Comparing version 3.0.1 to 5.0.0
/// <reference types="node" /> | ||
/// <reference types="node/http" /> | ||
/// <reference types="got/dist/source/utils/timed-out" /> | ||
import { Request } from '../@types'; | ||
@@ -3,0 +5,0 @@ import { Route } from '../Route'; |
/// <reference types="node" /> | ||
/// <reference types="node/http" /> | ||
/// <reference types="got/dist/source/utils/timed-out" /> | ||
import { NextFunction, Request } from '../@types'; | ||
@@ -3,0 +5,0 @@ /** |
/// <reference types="node" /> | ||
/// <reference types="node/http" /> | ||
/// <reference types="got/dist/source/utils/timed-out" /> | ||
import { NextFunction, Request } from '../@types'; | ||
@@ -3,0 +5,0 @@ /** |
@@ -215,4 +215,4 @@ "use strict"; | ||
function applyTemplate(template, req, parentTemplate) { | ||
if (null === template || 'undefined' === typeof template) { | ||
return ''; | ||
if (null === template) { | ||
return template; | ||
} | ||
@@ -224,9 +224,12 @@ if (Array.isArray(template)) { | ||
} | ||
const type = typeof template; | ||
switch (type) { | ||
switch (typeof template) { | ||
case 'function': | ||
return template(req, parentTemplate); | ||
case 'object': | ||
return Object.keys(template).reduce((obj, key) => { | ||
obj[key] = applyTemplate(template[key], req, template); | ||
const _template = template; | ||
return Object.keys(_template).reduce((obj, key) => { | ||
// undefined values cannot be set on headers or body | ||
if ('undefined' !== typeof _template[key]) { | ||
obj[key] = applyTemplate(_template[key], req, template); | ||
} | ||
return obj; | ||
@@ -236,6 +239,5 @@ }, {}); | ||
return String(template).replace(/^Symbol\((.*)\)$/, '$1'); | ||
default: | ||
return template; | ||
} | ||
return template; | ||
} | ||
//# sourceMappingURL=Router.js.map |
@@ -1,6 +0,5 @@ | ||
import got from 'got'; | ||
import { Stubborn } from '../../src/index'; | ||
export declare function init(): { | ||
sb: Stubborn; | ||
request: (path?: string, options?: {}) => got.GotPromise<string>; | ||
request: (path?: string, options?: {}) => import("got/dist/source").CancelableRequest<import("got/dist/source").Response<unknown>>; | ||
}; |
@@ -14,7 +14,8 @@ "use strict"; | ||
function request(path = '/', options = {}) { | ||
return got_1.default(`${sb.getOrigin()}${path}`, Object.assign({ | ||
return got_1.default(`${sb.getOrigin()}${path}`, { | ||
method: 'GET', | ||
json: true, | ||
responseType: 'json', | ||
throwHttpErrors: false, | ||
}, options)); | ||
...options, | ||
}); | ||
} | ||
@@ -21,0 +22,0 @@ return { sb, request }; |
{ | ||
"name": "stubborn-ws", | ||
"version": "3.0.1", | ||
"version": "5.0.0", | ||
"description": "Web server to mock external HTTP APIs in tests", | ||
@@ -45,13 +45,13 @@ "types": "dist/index.d.ts", | ||
"@types/got": "^9.6.7", | ||
"@types/hapi__accept": "^3.2.0", | ||
"@types/jest": "^24.0.18", | ||
"@types/hapi__accept": "^5.0.0", | ||
"@types/jest": "^24.0.22", | ||
"@types/lodash": "^4.14.138", | ||
"coveralls": "^3.0.6", | ||
"got": "^9.6.0", | ||
"jest": "^24.9.0", | ||
"jest-diff": "^24.9.0", | ||
"got": "^10.2.1", | ||
"jest": "^25.1.0", | ||
"jest-diff": "^25.1.0", | ||
"jsdoc-to-markdown": "^5.0.1", | ||
"prettier": "^1.18.2", | ||
"ts-jest": "^24.1.0", | ||
"tslint": "^5.20.0", | ||
"ts-jest": "^25.0.0", | ||
"tslint": "^6.0.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
@@ -58,0 +58,0 @@ "typescript": "^3.6.3" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
327866
6005