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

@netlify/functions

Package Overview
Dependencies
Maintainers
20
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netlify/functions - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0-v2api-1

dist/function/v2.d.ts

5

dist/function/handler.d.ts
import type { Context } from './context.js';
import type { Event } from './event.js';
import type { Response, BuilderResponse } from './response.js';
import type { Response, BuilderResponse, StreamingResponse } from './response.js';
export interface HandlerCallback<ResponseType extends Response = Response> {

@@ -15,1 +15,4 @@ (error: any, response: ResponseType): void;

export type BuilderHandler = BaseHandler<BuilderResponse, Context>;
export interface StreamingHandler {
(event: Event, context: Context): Promise<StreamingResponse>;
}
export { Context as HandlerContext } from './context.js';
export { Event as HandlerEvent } from './event.js';
export { BuilderHandler, Handler, BackgroundHandler, HandlerCallback } from './handler.js';
export { BuilderResponse, Response as HandlerResponse } from './response.js';
export { BuilderHandler, Handler, BackgroundHandler, HandlerCallback, StreamingHandler } from './handler.js';
export { BuilderResponse, Response as HandlerResponse, StreamingResponse } from './response.js';
export * from './v2.js';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = 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) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./v2.js"), exports);

@@ -0,1 +1,3 @@

/// <reference types="node" />
import type { PipelineSource } from 'node:stream';
export interface Response {

@@ -15,1 +17,4 @@ statusCode: number;

}
export interface StreamingResponse extends Omit<Response, 'body'> {
body?: string | PipelineSource<any>;
}

68

dist/lib/builder.js
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -18,34 +7,39 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.builder = void 0;
var is_promise_1 = __importDefault(require("is-promise"));
var consts_js_1 = require("./consts.js");
var augmentResponse = function (response) {
const is_promise_1 = __importDefault(require("is-promise"));
const consts_js_1 = require("./consts.js");
const augmentResponse = (response) => {
if (!response) {
return response;
}
var metadata = { version: consts_js_1.METADATA_VERSION, builder_function: consts_js_1.BUILDER_FUNCTIONS_FLAG, ttl: response.ttl || 0 };
return __assign(__assign({}, response), { metadata: metadata });
const metadata = { version: consts_js_1.METADATA_VERSION, builder_function: consts_js_1.BUILDER_FUNCTIONS_FLAG, ttl: response.ttl || 0 };
return {
...response,
metadata,
};
};
var wrapHandler = function (handler) {
const wrapHandler = (handler) =>
// eslint-disable-next-line promise/prefer-await-to-callbacks
(event, context, callback) => {
if (event.httpMethod !== 'GET' && event.httpMethod !== 'HEAD') {
return Promise.resolve({
body: 'Method Not Allowed',
statusCode: consts_js_1.HTTP_STATUS_METHOD_NOT_ALLOWED,
});
}
// Removing query string parameters from the builder function.
const modifiedEvent = {
...event,
multiValueQueryStringParameters: {},
queryStringParameters: {},
};
const wrappedCallback = (error, response) =>
// eslint-disable-next-line promise/prefer-await-to-callbacks
return function (event, context, callback) {
if (event.httpMethod !== 'GET' && event.httpMethod !== 'HEAD') {
return Promise.resolve({
body: 'Method Not Allowed',
statusCode: consts_js_1.HTTP_STATUS_METHOD_NOT_ALLOWED,
});
}
// Removing query string parameters from the builder function.
var modifiedEvent = __assign(__assign({}, event), { multiValueQueryStringParameters: {}, queryStringParameters: {} });
var wrappedCallback = function (error, response) {
// eslint-disable-next-line promise/prefer-await-to-callbacks
return callback ? callback(error, augmentResponse(response)) : null;
};
var execution = handler(modifiedEvent, context, wrappedCallback);
if ((0, is_promise_1.default)(execution)) {
// eslint-disable-next-line promise/prefer-await-to-then
return execution.then(augmentResponse);
}
return execution;
};
callback ? callback(error, augmentResponse(response)) : null;
const execution = handler(modifiedEvent, context, wrappedCallback);
if ((0, is_promise_1.default)(execution)) {
// eslint-disable-next-line promise/prefer-await-to-then
return execution.then(augmentResponse);
}
return execution;
};
exports.builder = wrapHandler;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.METADATA_VERSION = exports.HTTP_STATUS_OK = exports.HTTP_STATUS_METHOD_NOT_ALLOWED = exports.BUILDER_FUNCTIONS_FLAG = void 0;
var BUILDER_FUNCTIONS_FLAG = true;
const BUILDER_FUNCTIONS_FLAG = true;
exports.BUILDER_FUNCTIONS_FLAG = BUILDER_FUNCTIONS_FLAG;
var HTTP_STATUS_METHOD_NOT_ALLOWED = 405;
const HTTP_STATUS_METHOD_NOT_ALLOWED = 405;
exports.HTTP_STATUS_METHOD_NOT_ALLOWED = HTTP_STATUS_METHOD_NOT_ALLOWED;
var HTTP_STATUS_OK = 200;
const HTTP_STATUS_OK = 200;
exports.HTTP_STATUS_OK = HTTP_STATUS_OK;
var METADATA_VERSION = 1;
const METADATA_VERSION = 1;
exports.METADATA_VERSION = METADATA_VERSION;

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

*/
var schedule = function (cron, handler) { return handler; };
const schedule = (cron, handler) => handler;
exports.schedule = schedule;
export { builder } from './lib/builder.js';
export { schedule } from './lib/schedule.js';
export { stream } from './lib/stream.js';
export * from './function/index.js';

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.schedule = exports.builder = void 0;
exports.stream = exports.schedule = exports.builder = void 0;
var builder_js_1 = require("./lib/builder.js");

@@ -23,2 +23,4 @@ Object.defineProperty(exports, "builder", { enumerable: true, get: function () { return builder_js_1.builder; } });

Object.defineProperty(exports, "schedule", { enumerable: true, get: function () { return schedule_js_1.schedule; } });
var stream_js_1 = require("./lib/stream.js");
Object.defineProperty(exports, "stream", { enumerable: true, get: function () { return stream_js_1.stream; } });
__exportStar(require("./function/index.js"), exports);

@@ -5,3 +5,3 @@ {

"types": "./dist/main.d.ts",
"version": "1.5.0",
"version": "1.6.0-v2api-1",
"description": "JavaScript utilities for Netlify Functions",

@@ -56,2 +56,3 @@ "files": [

"dependencies": {
"@netlify/serverless-functions-api": "^1.5.1",
"is-promise": "^4.0.0"

@@ -71,4 +72,4 @@ },

"engines": {
"node": ">=8.3.0"
"node": ">=14.0.0"
}
}
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