@netlify/functions
Advanced tools
Comparing version 1.5.0 to 1.6.0-v2api-1
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>; | ||
} |
"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" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32369
33
695
2
2
3
+ Added@netlify/node-cookies@0.1.0(transitive)
+ Added@netlify/serverless-functions-api@1.31.0(transitive)
+ Addedurlpattern-polyfill@8.0.2(transitive)