@vercel/edge
Advanced tools
Comparing version 0.2.7 to 0.3.0
@@ -209,2 +209,54 @@ interface ModifiedRequest { | ||
/** | ||
* An extension to the standard `Request` object that is passed to every Edge Function. | ||
* | ||
* @example | ||
* ```ts | ||
* import type { RequestContext } from '@vercel/edge'; | ||
* | ||
* export default async function handler(request: Request, ctx: RequestContext): Promise<Response> { | ||
* // ctx is the RequestContext | ||
* } | ||
* ``` | ||
*/ | ||
interface RequestContext { | ||
/** | ||
* A method that can be used to keep the function running after a response has been sent. | ||
* This is useful when you have an async task that you want to keep running even after the | ||
* response has been sent and the request has ended. | ||
* | ||
* @example | ||
* | ||
* <caption>Sending an internal error to an error tracking service</caption> | ||
* | ||
* ```ts | ||
* import type { RequestContext } from '@vercel/edge'; | ||
* | ||
* export async function handleRequest(request: Request, ctx: RequestContext): Promise<Response> { | ||
* try { | ||
* return await myFunctionThatReturnsResponse(); | ||
* } catch (e) { | ||
* ctx.waitUntil((async () => { | ||
* // report this error to your error tracking service | ||
* await fetch('https://my-error-tracking-service.com', { | ||
* method: 'POST', | ||
* body: JSON.stringify({ | ||
* stack: e.stack, | ||
* message: e.message, | ||
* name: e.name, | ||
* url: request.url, | ||
* }), | ||
* }); | ||
* })()); | ||
* return new Response('Internal Server Error', { status: 500 }); | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
waitUntil( | ||
/** | ||
* A promise that will be kept alive until it resolves or rejects. | ||
*/ promise: Promise<unknown>): void; | ||
} | ||
/* eslint-disable no-var */ | ||
@@ -219,2 +271,2 @@ | ||
export { CITY_HEADER_NAME, COUNTRY_HEADER_NAME, ExtraResponseInit, Geo, IP_HEADER_NAME, LATITUDE_HEADER_NAME, LONGITUDE_HEADER_NAME, ModifiedRequest, REGION_HEADER_NAME, REQUEST_ID_HEADER_NAME, geolocation, ipAddress, json, next, rewrite }; | ||
export { CITY_HEADER_NAME, COUNTRY_HEADER_NAME, ExtraResponseInit, Geo, IP_HEADER_NAME, LATITUDE_HEADER_NAME, LONGITUDE_HEADER_NAME, ModifiedRequest, REGION_HEADER_NAME, REQUEST_ID_HEADER_NAME, RequestContext, geolocation, ipAddress, json, next, rewrite }; |
{ | ||
"name": "@vercel/edge", | ||
"version": "0.2.7", | ||
"version": "0.3.0", | ||
"license": "MIT", | ||
@@ -43,3 +43,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "25f6595d3698546ba69c7fe9f601a906167fef3f" | ||
"gitHead": "7845bef8268b191f422f493fca6e2772bee7ac86" | ||
} |
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
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
27398
462