Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "apicase", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Create, group and manage your APIs with json declaration", | ||
@@ -5,0 +5,0 @@ "author": "kelin2025", |
@@ -61,7 +61,7 @@ import pick from 'lodash/pick' | ||
)) | ||
clone.config.mixins = mapValues({ | ||
...clone.container.mixins, | ||
...clone.config.mixins, | ||
...params.mixins || {} | ||
}, Utils.normalizeMixin) | ||
clone.config.mixins = mapValues(assign( | ||
clone.container.mixins, | ||
clone.config.mixins, | ||
params.mixins || {} | ||
), Utils.normalizeMixin) | ||
@@ -85,11 +85,17 @@ let callback = async function callService (ctx, next) { | ||
ctx.response = await fetch(url, options) | ||
ctx.result = await ctx.response.json() | ||
if (ctx.response.ok) { | ||
ctx.result = await ctx.response.json() | ||
} else { | ||
throw new Error('Failed to fetch') | ||
} | ||
} | ||
ctx.success = true | ||
forEach(ctx.config.mixins, (mixin, name) => { | ||
Object.defineProperty(ctx, name, { | ||
...mapValues(pick(mixin), ['get', 'set'], mixin => mixin.bind(ctx)), | ||
enumerable: true, | ||
configurable: false | ||
}) | ||
Object.defineProperty(ctx, name, assign( | ||
{ | ||
enumerable: true, | ||
configurable: false | ||
}, | ||
mapValues(pick(mixin), ['get', 'set'], mixin => mixin.bind(ctx)), | ||
)) | ||
}) | ||
@@ -96,0 +102,0 @@ next() |
@@ -98,3 +98,3 @@ import has from 'lodash/has' | ||
let url = `${ctx.container.base}${ctx.config.url}` | ||
return pathToRegexp.compile(( | ||
return pathToRegexp.compile( | ||
ctx.config.method === 'GET' | ||
@@ -101,0 +101,0 @@ ? url + jsonToQueryString(data) |
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
9828
311