0.34.1 • Published 3 years ago
@netlify/edge-handler-types v0.34.1
@netlify/edge-handler-types`
This package contains TypeScript typings for writing Netlify Edge Handlers.
Installation
npm install --save-dev @netlify/edge-handler-types
or if you prefer yarn
yarn add -D @netlify/edge-handler-types
Configuring tsconfig.json
For the typings to work it is vitally important TypeScript does not try to include its own definitions of global types (e. g. those found normally in a Browser environment).
Thus, it's important you configure the lib
and typeRoots
properties in your tsconfig.json
:
{
"compilerOptions": {
"lib": ["ES2020"],
"typeRoots": [
"node_modules/@types", // If you use type definitions of other packages
"node_modules/@netlify" // Include this line for Edge Handler types
]
}
}
Writing Edge Handlers with this package
The types are injected into the global scope. No additional imports are necessary.
export const onRequest: EdgeHandler = (ev: RequestEvent) => {
const headers = {
"content-type": "text/plain",
"x-cool": "yes",
};
ev.replaceResponse(
new Response("Sent from an Edge Handler written in TypeScript!", { headers }),
);
};
0.34.1
3 years ago
0.34.0
3 years ago
0.33.0-pre.2
3 years ago
0.33.0-pre.3
3 years ago
0.33.0-pre.0
3 years ago
0.33.0-pre.1
3 years ago
0.33.2
3 years ago
0.33.1
3 years ago
0.33.0-pre.4
3 years ago
0.33.0
3 years ago
0.32.0-pre.1
3 years ago
0.32.0-pre.2
3 years ago
0.32.0
3 years ago
0.32.0-pre.0
3 years ago
0.31.0
3 years ago
0.30.2
3 years ago
0.1.1
4 years ago
0.1.0
4 years ago