@remix-run/cloudflare-pages
Advanced tools
Comparing version 0.0.0-experimental-56ff64d1 to 0.0.0-experimental-583953af
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-56ff64d1 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-583953af | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-56ff64d1 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-583953af | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-56ff64d1 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-583953af | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-56ff64d1 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-583953af | ||
* | ||
@@ -13,4 +13,4 @@ * Copyright (c) Remix Software Inc. | ||
export { createCloudflareKVSessionStorage } from './sessions/cloudflareKVSessionStorage.js'; | ||
export { createFetchHandler, createRequestHandler } from './worker.js'; | ||
export { createPagesFunctionHandler, createRequestHandler } from './worker.js'; | ||
installGlobals(); |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-56ff64d1 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-583953af | ||
* | ||
@@ -18,2 +18,4 @@ * Copyright (c) Remix Software Inc. | ||
* KV Store may contain much more data than cookies. | ||
* | ||
* @see https://remix.run/api/remix#createcloudflarekvsessionstorage-cloudflare-workers | ||
*/ | ||
@@ -20,0 +22,0 @@ function createCloudflareKVSessionStorage({ |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-56ff64d1 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-583953af | ||
* | ||
@@ -25,10 +25,3 @@ * Copyright (c) Remix Software Inc. | ||
} | ||
async function handleAsset(request, env) { | ||
let envWithAssets = env; | ||
const response = await envWithAssets.ASSETS.fetch(request); | ||
if (response.ok) return response; | ||
} | ||
function createFetchHandler({ | ||
function createPagesFunctionHandler({ | ||
build, | ||
@@ -45,7 +38,11 @@ getLoadContext, | ||
const handleFetch = async context => { | ||
let response; | ||
let url = new URL(context.request.url); | ||
response = // TODO: Remove this once a fix has been meged to wranger@v2 | ||
process.env.NODE_ENV === "development" && url.pathname === "/" ? undefined : await handleAsset(context.request.clone(), context.env); | ||
let response; // https://github.com/cloudflare/wrangler2/issues/117 | ||
context.request.headers.delete("if-none-match"); | ||
try { | ||
response = await context.env.ASSETS.fetch(context.request.url, context.request.clone()); | ||
response = response && response.status >= 200 && response.status < 400 ? new Response(response.body, response) : undefined; | ||
} catch {} | ||
if (!response) { | ||
@@ -76,2 +73,2 @@ response = await handleRequest(context); | ||
export { createFetchHandler, createRequestHandler }; | ||
export { createPagesFunctionHandler, createRequestHandler }; |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-56ff64d1 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-583953af | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
export { createCloudflareKVSessionStorage } from "./sessions/cloudflareKVSessionStorage"; | ||
export type { CreateFetchHandlerParams } from "./worker"; | ||
export { createFetchHandler, createRequestHandler } from "./worker"; | ||
export type { createPagesFunctionHandlerParams } from "./worker"; | ||
export { createPagesFunctionHandler, createRequestHandler } from "./worker"; |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-56ff64d1 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-583953af | ||
* | ||
@@ -22,3 +22,3 @@ * Copyright (c) Remix Software Inc. | ||
exports.createCloudflareKVSessionStorage = cloudflareKVSessionStorage.createCloudflareKVSessionStorage; | ||
exports.createFetchHandler = worker.createFetchHandler; | ||
exports.createPagesFunctionHandler = worker.createPagesFunctionHandler; | ||
exports.createRequestHandler = worker.createRequestHandler; |
{ | ||
"name": "@remix-run/cloudflare-pages", | ||
"description": "Cloudflare Pages request handler for Remix", | ||
"version": "0.0.0-experimental-56ff64d1", | ||
"version": "0.0.0-experimental-583953af", | ||
"license": "MIT", | ||
@@ -17,3 +17,3 @@ "main": "./index.js", | ||
"dependencies": { | ||
"@remix-run/server-runtime": "0.0.0-experimental-56ff64d1" | ||
"@remix-run/server-runtime": "0.0.0-experimental-583953af" | ||
}, | ||
@@ -24,4 +24,5 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@cloudflare/workers-types": "^3.2.0" | ||
"@cloudflare/workers-types": "^3.2.0", | ||
"@types/mime": "^2.0.3" | ||
} | ||
} |
@@ -19,4 +19,6 @@ /// <reference types="@cloudflare/workers-types" /> | ||
* KV Store may contain much more data than cookies. | ||
* | ||
* @see https://remix.run/api/remix#createcloudflarekvsessionstorage-cloudflare-workers | ||
*/ | ||
export declare function createCloudflareKVSessionStorage({ cookie, kv }: KVSessionStorageOptions): SessionStorage; | ||
export declare function createCloudflareKVSessionStorage({ cookie, kv, }: KVSessionStorageOptions): SessionStorage; | ||
export {}; |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-56ff64d1 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-583953af | ||
* | ||
@@ -22,2 +22,4 @@ * Copyright (c) Remix Software Inc. | ||
* KV Store may contain much more data than cookies. | ||
* | ||
* @see https://remix.run/api/remix#createcloudflarekvsessionstorage-cloudflare-workers | ||
*/ | ||
@@ -24,0 +26,0 @@ function createCloudflareKVSessionStorage({ |
/// <reference types="@cloudflare/workers-types" /> | ||
import type { ServerBuild, AppLoadContext } from "@remix-run/server-runtime"; | ||
export interface CreateFetchHandlerParams<Env = any> { | ||
export interface createPagesFunctionHandlerParams<Env = any> { | ||
build: ServerBuild; | ||
@@ -8,3 +8,3 @@ getLoadContext?: (context: EventContext<Env, any, any>) => AppLoadContext; | ||
} | ||
export declare function createRequestHandler<Env = any>({ build, getLoadContext, mode }: CreateFetchHandlerParams<Env>): PagesFunction<Env>; | ||
export declare function createFetchHandler<Env = any>({ build, getLoadContext, mode }: CreateFetchHandlerParams<Env>): (context: EventContext<Env, any, any>) => Promise<Response>; | ||
export declare function createRequestHandler<Env = any>({ build, getLoadContext, mode, }: createPagesFunctionHandlerParams<Env>): PagesFunction<Env>; | ||
export declare function createPagesFunctionHandler<Env = any>({ build, getLoadContext, mode, }: createPagesFunctionHandlerParams<Env>): (context: EventContext<Env, any, any>) => Promise<Response>; |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-56ff64d1 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-583953af | ||
* | ||
@@ -29,10 +29,3 @@ * Copyright (c) Remix Software Inc. | ||
} | ||
async function handleAsset(request, env) { | ||
let envWithAssets = env; | ||
const response = await envWithAssets.ASSETS.fetch(request); | ||
if (response.ok) return response; | ||
} | ||
function createFetchHandler({ | ||
function createPagesFunctionHandler({ | ||
build, | ||
@@ -49,7 +42,11 @@ getLoadContext, | ||
const handleFetch = async context => { | ||
let response; | ||
let url = new URL(context.request.url); | ||
response = // TODO: Remove this once a fix has been meged to wranger@v2 | ||
process.env.NODE_ENV === "development" && url.pathname === "/" ? undefined : await handleAsset(context.request.clone(), context.env); | ||
let response; // https://github.com/cloudflare/wrangler2/issues/117 | ||
context.request.headers.delete("if-none-match"); | ||
try { | ||
response = await context.env.ASSETS.fetch(context.request.url, context.request.clone()); | ||
response = response && response.status >= 200 && response.status < 400 ? new Response(response.body, response) : undefined; | ||
} catch {} | ||
if (!response) { | ||
@@ -80,3 +77,3 @@ response = await handleRequest(context); | ||
exports.createFetchHandler = createFetchHandler; | ||
exports.createPagesFunctionHandler = createPagesFunctionHandler; | ||
exports.createRequestHandler = createRequestHandler; |
18313
2
2
+ Added@remix-run/server-runtime@0.0.0-experimental-583953af(transitive)
- Removed@remix-run/server-runtime@0.0.0-experimental-56ff64d1(transitive)
Updated@remix-run/server-runtime@0.0.0-experimental-583953af