From cd59a7b594544b00751231757c17499da8ea3a6e Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Fri, 19 Jul 2024 23:24:22 -0700 Subject: [PATCH] :memo: Update docs based on latest APIs --- packages/superflare/docs/getting-started.md | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/superflare/docs/getting-started.md b/packages/superflare/docs/getting-started.md index fa86d32..eda2556 100644 --- a/packages/superflare/docs/getting-started.md +++ b/packages/superflare/docs/getting-started.md @@ -32,16 +32,22 @@ npm install @superflare/remix Then, in your `worker.ts` file, import the `handleFetch` function from `@superflare/remix`, and import your local `superflare.config.ts` as `config`: ```ts +import { createRequestHandler, type ServerBuild } from "@remix-run/cloudflare"; import { handleFetch } from "@superflare/remix"; import config from "./superflare.config"; +import * as build from "./build/server"; +import __STATIC_CONTENT_MANIFEST from "__STATIC_CONTENT_MANIFEST"; + +const MANIFEST = JSON.parse(__STATIC_CONTENT_MANIFEST); +const handleRemixRequest = createRequestHandler(build as any as ServerBuild); export default { - async fetch(request: Request, env: Env, ctx: ExecutionContext) { + async fetch(request, env, ctx) { // ... - return handleFetch(request, env, ctx, config, remixHandler); + return handleFetch(request, env, ctx, config, handleRemixRequest); }, -}; +} satisfies ExportedHandler }>; ``` If you plan to use [Queues](/queues), you'll also need to import the `handleQueue` function from `superflare` and handle that in your `worker.ts` file: @@ -53,19 +59,15 @@ import config './superflare.config'; export default { // ... - async queue( - batch: MessageBatch, - env: Env, - ctx: ExecutionContext - ): Promise { + async queue(batch, env, ctx) { return handleQueue(batch, env, ctx, config); }, -} +} satisfies ExportedHandler }>; ``` Behind the scenes, Superflare creates a [cookie-based session storage](https://remix.run/docs/en/1.14.1/utils/sessions#createcookiesessionstorage) for you and instantiates the Superflare request handler. -It also injects `auth`, `session`, `env`, and `ctx` to your `AppContext` which is available in your loaders and actions. +It also injects `auth`, `session`, and `cloudflare` objects into your `AppContext` which is available in your loaders and actions. The `cloudflare` object matches the return value of [Wrangler’s `getPlatformProxy`](https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy). {% callout title="Cookie Monster" %} Superflare automatically commits your session data to the outgoing response's `set-cookie` header, so you don't need to worry about that like you do in a standard Remix app.