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

@webiny/handler-http

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webiny/handler-http - npm Package Compare versions

Comparing version 5.30.0 to 5.31.0-beta.0

7

index.d.ts

@@ -1,4 +0,5 @@

import { HandlerHttpOptions } from "./types";
import { Plugin } from "@webiny/plugins";
declare const _default: (options?: HandlerHttpOptions) => Plugin[];
/**
* Dummy file
*/
declare const _default: (_: any) => never[];
export default _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -10,118 +8,10 @@ value: true

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _handler = require("@webiny/handler");
var _boolean = require("boolean");
var _utils = require("@webiny/utils");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
const DEFAULT_HEADERS = _objectSpread({
"Cache-Control": "no-store",
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
"Access-Control-Allow-Methods": "OPTIONS,POST"
}, (0, _utils.getWebinyVersionHeaders)());
const OPTIONS_HEADERS = {
"Access-Control-Max-Age": "86400",
"Cache-Control": "public, max-age=86400"
/**
* Dummy file
*/
// eslint-disable-next-line
var _default = _ => {
return [];
};
const OPTION_STATUS_CODE = 204;
const lowercaseKeys = obj => {
return Object.keys(obj).reduce((acc, key) => {
acc[key.toLowerCase()] = obj[key];
return acc;
}, {});
};
var _default = (options = {}) => [new _handler.ContextPlugin(async context => {
const {
invocationArgs
} = context;
if (!invocationArgs || !invocationArgs.method) {
return;
}
if (invocationArgs.method.toLowerCase() === "options") {
context.setResult({
statusCode: OPTION_STATUS_CODE,
body: "",
headers: _objectSpread(_objectSpread({}, DEFAULT_HEADERS), OPTIONS_HEADERS)
});
return;
}
const path = invocationArgs.path ?? {
base: "",
parameters: {},
query: ""
};
const request = {
method: invocationArgs.method,
body: invocationArgs.body,
headers: lowercaseKeys(invocationArgs.headers || {}),
cookies: invocationArgs.cookies,
path: {
base: path.base,
parameters: path.parameters,
query: path.query
}
};
context.http = {
request,
response({
statusCode = 200,
body = "",
headers = {}
}) {
return {
statusCode,
body,
headers
};
}
};
}), new _handler.HandlerErrorPlugin(async (context, error) => {
if (!context.http || typeof context.http.response !== "function") {
return error;
}
const debug = (0, _boolean.boolean)(options.debug);
if (debug) {
return context.http.response({
statusCode: 500,
body: JSON.stringify({
error: {
name: error.constructor.name,
message: error.message,
stack: error.stack
}
}),
headers: DEFAULT_HEADERS
});
}
return context.http.response({
statusCode: 500,
body: JSON.stringify({
error: {
name: "Error",
message: "Internal Server Error"
}
}),
headers: DEFAULT_HEADERS
});
})];
exports.default = _default;
{
"name": "@webiny/handler-http",
"version": "5.30.0",
"version": "5.31.0-beta.0",
"main": "index.js",

@@ -17,8 +17,3 @@ "repository": {

"dependencies": {
"@babel/runtime": "7.18.6",
"@webiny/handler": "5.30.0",
"@webiny/handler-args": "5.30.0",
"@webiny/plugins": "5.30.0",
"@webiny/utils": "5.30.0",
"boolean": "3.2.0"
"@babel/runtime": "7.18.9"
},

@@ -28,4 +23,4 @@ "devDependencies": {

"@babel/core": "^7.16.0",
"@webiny/cli": "^5.30.0",
"@webiny/project-utils": "^5.30.0",
"@webiny/cli": "^5.31.0-beta.0",
"@webiny/project-utils": "^5.31.0-beta.0",
"merge": "^1.2.1",

@@ -43,3 +38,3 @@ "rimraf": "^3.0.2",

},
"gitHead": "3cadc5d26e565586b28772afbc18ae554ce7b782"
"gitHead": "dea7c56325ff140ef0e2d761f3e65708d46d401e"
}

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