New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@api-ts/express-wrapper

Package Overview
Dependencies
Maintainers
2
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.0.0-beta.9 to 1.0.0-beta.10

12

dist/src/request.js

@@ -8,3 +8,7 @@ "use strict";

if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -39,3 +43,3 @@ if (k2 === undefined) k2 = k;

const decodeRequestAndEncodeResponse = (apiName, httpRoute, handler, responseEncoder) => {
return createNamedFunction('decodeRequestAndEncodeResponse' + httpRoute.method + apiName, async (req, res) => {
return createNamedFunction('decodeRequestAndEncodeResponse' + httpRoute.method + apiName, async (req, res, next) => {
const maybeRequest = httpRoute.request.decode(req);

@@ -58,5 +62,7 @@ if (maybeRequest._tag === 'Left') {

res.status(500).end();
next();
return;
}
responseEncoder(httpRoute, rawResponse, res);
const expressHandler = responseEncoder(httpRoute, rawResponse);
expressHandler(req, res, next);
});

@@ -63,0 +69,0 @@ };

@@ -10,4 +10,4 @@ import express from 'express';

}[keyof R['response'] & keyof HttpToKeyStatus];
export declare type ResponseEncoder = (route: HttpRoute, serviceFnResponse: NumericOrKeyedResponseType<HttpRoute>, expressRes: express.Response) => void;
export declare type ResponseEncoder = (route: HttpRoute, serviceFnResponse: NumericOrKeyedResponseType<HttpRoute>) => express.RequestHandler;
export declare const defaultResponseEncoder: ResponseEncoder;
//# sourceMappingURL=response.d.ts.map

@@ -5,3 +5,3 @@ "use strict";

const io_ts_http_1 = require("@api-ts/io-ts-http");
const defaultResponseEncoder = (route, serviceFnResponse, expressRes) => {
const defaultResponseEncoder = (route, serviceFnResponse) => (_req, res) => {
const { type, payload } = serviceFnResponse;

@@ -11,14 +11,15 @@ const status = typeof type === 'number' ? type : io_ts_http_1.KeyToHttpStatus[type];

console.warn('Unknown status code returned');
expressRes.status(500).end();
res.status(500).end();
return;
}
const responseCodec = route.response[status];
if (responseCodec === undefined || !responseCodec.is(payload)) {
try {
res.status(status).json(responseCodec.encode(payload)).end();
}
catch {
console.warn("Unable to encode route's return value, did you return the expected type?");
expressRes.status(500).end();
return;
res.status(500).end();
}
expressRes.status(status).json(responseCodec.encode(payload)).end();
};
exports.defaultResponseEncoder = defaultResponseEncoder;
//# sourceMappingURL=response.js.map
{
"name": "@api-ts/express-wrapper",
"version": "1.0.0-beta.9",
"version": "1.0.0-beta.10",
"description": "Implement an HTTP specification with Express",

@@ -27,7 +27,6 @@ "author": "Eric Crosson <ericcrosson@bitgo.com>",

"@types/express": "4.17.13",
"@types/node": "16.11.7",
"ava": "4.0.1",
"ava": "4.2.0",
"c8": "7.11.2",
"ts-node": "10.4.0",
"typescript": "4.5.5"
"ts-node": "10.7.0",
"typescript": "4.6.4"
},

@@ -34,0 +33,0 @@ "ava": {

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

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