@remix-run/cloudflare-pages
Advanced tools
Comparing version 0.0.0-experimental-5d79f855 to 0.0.0-experimental-5ddceecc
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5d79f855 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5ddceecc | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5d79f855 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5ddceecc | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5d79f855 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5ddceecc | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5d79f855 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5ddceecc | ||
* | ||
@@ -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-5d79f855 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5ddceecc | ||
* | ||
@@ -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-5d79f855 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5ddceecc | ||
* | ||
@@ -11,3 +11,2 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
import { getType } from 'mime'; | ||
import { createRequestHandler as createRequestHandler$1 } from '@remix-run/server-runtime'; | ||
@@ -27,3 +26,3 @@ | ||
} | ||
function createFetchHandler({ | ||
function createPagesFunctionHandler({ | ||
build, | ||
@@ -33,3 +32,3 @@ getLoadContext, | ||
}) { | ||
const handleRequest = createRequestHandler({ | ||
let handleRequest = createRequestHandler({ | ||
build, | ||
@@ -40,20 +39,12 @@ getLoadContext, | ||
const handleFetch = async context => { | ||
let response; | ||
let url = new URL(context.request.url); | ||
let handleFetch = async context => { | ||
let response; // https://github.com/cloudflare/wrangler2/issues/117 | ||
context.request.headers.delete("if-none-match"); | ||
try { | ||
response = await context.next(); | ||
response = response.ok ? response : undefined; | ||
} catch {} // This is a known CF bug in the Pages runtime | ||
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) { | ||
let contentType = getType(url.pathname); | ||
if (contentType) { | ||
response.headers.set("Content-Type", contentType); | ||
} | ||
} | ||
if (!response) { | ||
@@ -84,2 +75,2 @@ response = await handleRequest(context); | ||
export { createFetchHandler, createRequestHandler }; | ||
export { createPagesFunctionHandler, createRequestHandler }; |
/** | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5d79f855 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5ddceecc | ||
* | ||
@@ -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-5d79f855 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5ddceecc | ||
* | ||
@@ -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-5d79f855", | ||
"version": "0.0.0-experimental-5ddceecc", | ||
"license": "MIT", | ||
@@ -17,4 +17,3 @@ "main": "./index.js", | ||
"dependencies": { | ||
"@remix-run/server-runtime": "0.0.0-experimental-5d79f855", | ||
"mime": "^3.0.0" | ||
"@remix-run/server-runtime": "0.0.0-experimental-5ddceecc" | ||
}, | ||
@@ -21,0 +20,0 @@ "peerDependencies": { |
@@ -8,3 +8,3 @@ # Welcome to Remix! | ||
```sh | ||
$ npx create-remix@latest | ||
npx create-remix@latest | ||
``` | ||
@@ -11,0 +11,0 @@ |
@@ -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-5d79f855 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5ddceecc | ||
* | ||
@@ -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-5d79f855 | ||
* @remix-run/cloudflare-pages v0.0.0-experimental-5ddceecc | ||
* | ||
@@ -15,3 +15,2 @@ * Copyright (c) Remix Software Inc. | ||
var mime = require('mime'); | ||
var serverRuntime = require('@remix-run/server-runtime'); | ||
@@ -31,3 +30,3 @@ | ||
} | ||
function createFetchHandler({ | ||
function createPagesFunctionHandler({ | ||
build, | ||
@@ -37,3 +36,3 @@ getLoadContext, | ||
}) { | ||
const handleRequest = createRequestHandler({ | ||
let handleRequest = createRequestHandler({ | ||
build, | ||
@@ -44,20 +43,12 @@ getLoadContext, | ||
const handleFetch = async context => { | ||
let response; | ||
let url = new URL(context.request.url); | ||
let handleFetch = async context => { | ||
let response; // https://github.com/cloudflare/wrangler2/issues/117 | ||
context.request.headers.delete("if-none-match"); | ||
try { | ||
response = await context.next(); | ||
response = response.ok ? response : undefined; | ||
} catch {} // This is a known CF bug in the Pages runtime | ||
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) { | ||
let contentType = mime.getType(url.pathname); | ||
if (contentType) { | ||
response.headers.set("Content-Type", contentType); | ||
} | ||
} | ||
if (!response) { | ||
@@ -88,3 +79,3 @@ response = await handleRequest(context); | ||
exports.createFetchHandler = createFetchHandler; | ||
exports.createPagesFunctionHandler = createPagesFunctionHandler; | ||
exports.createRequestHandler = createRequestHandler; |
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
18303
2
476
+ Added@remix-run/server-runtime@0.0.0-experimental-5ddceecc(transitive)
- Removedmime@^3.0.0
- Removed@remix-run/server-runtime@0.0.0-experimental-5d79f855(transitive)
- Removedmime@3.0.0(transitive)
Updated@remix-run/server-runtime@0.0.0-experimental-5ddceecc