-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: bring fixtures in line with templates
Co-authored-by: Matt Brophy <[email protected]>
- Loading branch information
1 parent
ebc148c
commit 091a676
Showing
59 changed files
with
530 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
.../fixtures/cloudflare/app/routes/index.tsx → ...helpers/cf-template/app/routes/_index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
/// <reference types="@remix-run/dev" /> | ||
/// <reference types="@remix-run/cloudflare-workers/globals" /> | ||
/// <reference types="@remix-run/cloudflare" /> | ||
/// <reference types="@cloudflare/workers-types" /> | ||
|
||
declare module "__STATIC_CONTENT_MANIFEST" { | ||
const manifest: string; | ||
export default manifest; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,53 @@ | ||
import { createEventHandler } from "@remix-run/cloudflare-workers"; | ||
import { getAssetFromKV } from "@cloudflare/kv-asset-handler"; | ||
import type { AppLoadContext } from "@remix-run/cloudflare"; | ||
import { createRequestHandler, logDevReady } from "@remix-run/cloudflare"; | ||
import * as build from "@remix-run/dev/server-build"; | ||
import __STATIC_CONTENT_MANIFEST from "__STATIC_CONTENT_MANIFEST"; | ||
|
||
addEventListener("fetch", createEventHandler({ build, mode: build.mode })); | ||
const MANIFEST = JSON.parse(__STATIC_CONTENT_MANIFEST); | ||
const handleRemixRequest = createRequestHandler(build, process.env.NODE_ENV); | ||
|
||
if (process.env.NODE_ENV === "development") { | ||
logDevReady(build); | ||
} | ||
|
||
export default { | ||
async fetch( | ||
request: Request, | ||
env: { | ||
__STATIC_CONTENT: Fetcher; | ||
}, | ||
ctx: ExecutionContext | ||
): Promise<Response> { | ||
try { | ||
const url = new URL(request.url); | ||
const ttl = url.pathname.startsWith("/build/") | ||
? 60 * 60 * 24 * 365 // 1 year | ||
: 60 * 5; // 5 minutes | ||
return await getAssetFromKV( | ||
{ | ||
request, | ||
waitUntil: ctx.waitUntil.bind(ctx), | ||
} as FetchEvent, | ||
{ | ||
ASSET_NAMESPACE: env.__STATIC_CONTENT, | ||
ASSET_MANIFEST: MANIFEST, | ||
cacheControl: { | ||
browserTTL: ttl, | ||
edgeTTL: ttl, | ||
}, | ||
} | ||
); | ||
} catch (error) {} | ||
|
||
try { | ||
const loadContext: AppLoadContext = { | ||
env, | ||
}; | ||
return await handleRemixRequest(request, loadContext); | ||
} catch (error) { | ||
console.log(error); | ||
return new Response("An unexpected error occurred", { status: 500 }); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,9 @@ | ||
name = "remix-cloudflare-workers" | ||
type = "javascript" | ||
compatibility_date = "2022-04-05" | ||
compatibility_flags = ["streams_enable_constructors"] | ||
|
||
zone_id = "" | ||
account_id = "" | ||
route = "" | ||
workers_dev = true | ||
main = "./build/index.js" | ||
# https://developers.cloudflare.com/workers/platform/compatibility-dates | ||
compatibility_date = "2023-04-20" | ||
|
||
[site] | ||
bucket = "./public" | ||
entry-point = "." | ||
|
||
[build] | ||
command = "npm run build" | ||
|
||
[build.upload] | ||
format="service-worker" | ||
bucket = "./public" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as React from "react"; | ||
import type { MetaFunction } from "@remix-run/deno"; | ||
|
||
export const meta: MetaFunction = () => { | ||
return [ | ||
{ title: "New Remix App" }, | ||
{ name: "description", content: "Welcome to Remix!" }, | ||
]; | ||
}; | ||
|
||
export default function Index() { | ||
return ( | ||
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}> | ||
<h1>Welcome to Remix</h1> | ||
<ul> | ||
<li> | ||
<a | ||
target="_blank" | ||
href="https://remix.run/tutorials/blog" | ||
rel="noreferrer" | ||
> | ||
15m Quickstart Blog Tutorial | ||
</a> | ||
</li> | ||
<li> | ||
<a | ||
target="_blank" | ||
href="https://remix.run/tutorials/jokes" | ||
rel="noreferrer" | ||
> | ||
Deep Dive Jokes App Tutorial | ||
</a> | ||
</li> | ||
<li> | ||
<a target="_blank" href="https://remix.run/docs" rel="noreferrer"> | ||
Remix Docs | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.