Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@api-ts/superagent-wrapper

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@api-ts/superagent-wrapper - npm Package Compare versions

Comparing version 0.2.0-beta.12 to 0.2.0-beta.13

8

dist/src/request.d.ts

@@ -10,8 +10,12 @@ import * as h from '@api-ts/io-ts-http';

}[keyof Route['response']];
declare type DecodedResponse<Route extends h.HttpRoute> = SuccessfulResponses<Route> | {
export declare type DecodedResponse<Route extends h.HttpRoute> = SuccessfulResponses<Route> | {
status: 'decodeError';
error: unknown;
error: string;
body: unknown;
original: Response;
};
export declare class DecodeError extends Error {
readonly decodedResponse: DecodedResponse<h.HttpRoute>;
constructor(message: string, decodedResponse: DecodedResponse<h.HttpRoute>);
}
declare type ExpectedDecodedResponse<Route extends h.HttpRoute, StatusCode extends keyof Route['response']> = DecodedResponse<Route> & {

@@ -18,0 +22,0 @@ status: StatusCode;

@@ -26,6 +26,14 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.requestForRoute = exports.supertestRequestFactory = exports.superagentRequestFactory = void 0;
exports.requestForRoute = exports.supertestRequestFactory = exports.superagentRequestFactory = exports.DecodeError = void 0;
const E = __importStar(require("fp-ts/Either"));
const PathReporter = __importStar(require("io-ts/lib/PathReporter"));
const url_1 = require("url");
const function_1 = require("fp-ts/function");
class DecodeError extends Error {
constructor(message, decodedResponse) {
super(message);
this.decodedResponse = decodedResponse;
}
}
exports.DecodeError = DecodeError;
const decodedResponse = (res) => res;

@@ -80,3 +88,3 @@ const METHOD_MAP = {

status: 'decodeError',
error,
error: PathReporter.failure(error).join('\n'),
body: res.body,

@@ -87,7 +95,10 @@ original: res,

patchedReq.decodeExpecting = (status) => patchedReq.decode().then((res) => {
var _a;
if (res.status !== status) {
const error = (_a = res.error) !== null && _a !== void 0 ? _a : `Unexpected status code ${String(res.status)}`;
throw new Error(JSON.stringify(error));
if (res.original.status !== status) {
const error = `Unexpected response ${String(res.original.status)}: ${JSON.stringify(res.original.body)}`;
throw new DecodeError(error, res);
}
else if (res.status === 'decodeError') {
const error = `Could not decode response ${String(res.original.status)}: ${JSON.stringify(res.original.body)}`;
throw new DecodeError(error, res);
}
else {

@@ -94,0 +105,0 @@ return res;

{
"name": "@api-ts/superagent-wrapper",
"version": "0.2.0-beta.12",
"version": "0.2.0-beta.13",
"description": "Make type-safe HTTP requests with superagent",

@@ -5,0 +5,0 @@ "author": "Patrick McLaughlin <patrickmclaughlin@bitgo.com>",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc