Skip to content

Commit

Permalink
update packages, clean up remix version
Browse files Browse the repository at this point in the history
  • Loading branch information
kyh committed Sep 6, 2023
1 parent 515eb09 commit 51034e0
Show file tree
Hide file tree
Showing 14 changed files with 9,630 additions and 15,688 deletions.
25 changes: 8 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
node_modules

build
dist
.turbo
.vercel
.cache
/.cache
/.output
/.vercel
/api/index.js
/api/index.js.map
/api/metafile.*
/build
/public/build
.env
.output

public/build
api/index.js
api/index.js.map

.env
.env.local
.env.development
.env.production

app/tailwind.css
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.17.0
18.17.1
18 changes: 16 additions & 2 deletions app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
/**
* By default, Remix will handle hydrating your app on the client for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.client
*/

import { RemixBrowser } from "@remix-run/react";
import { hydrate } from "react-dom";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";

hydrate(<RemixBrowser />, document);
startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>
);
});
132 changes: 123 additions & 9 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,135 @@
import type { EntryContext } from "@remix-run/node";
/**
* By default, Remix will handle generating the HTTP Response for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.server
*/

import { PassThrough } from "node:stream";

import type { AppLoadContext, EntryContext } from "@remix-run/node";
import { Response } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import { renderToString } from "react-dom/server";
import isbot from "isbot";
import { renderToPipeableStream } from "react-dom/server";

const ABORT_DELAY = 5_000;

export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
loadContext: AppLoadContext
) {
return isbot(request.headers.get("user-agent"))
? handleBotRequest(
request,
responseStatusCode,
responseHeaders,
remixContext
)
: handleBrowserRequest(
request,
responseStatusCode,
responseHeaders,
remixContext
);
}

function handleBotRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
const markup = renderToString(
<RemixServer context={remixContext} url={request.url} />
);
return new Promise((resolve, reject) => {
let shellRendered = false;
const { pipe, abort } = renderToPipeableStream(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
{
onAllReady() {
shellRendered = true;
const body = new PassThrough();

responseHeaders.set("Content-Type", "text/html");

resolve(
new Response(body, {
headers: responseHeaders,
status: responseStatusCode,
})
);

pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
responseStatusCode = 500;
// Log streaming rendering errors from inside the shell. Don't log
// errors encountered during initial shell rendering since they'll
// reject and get logged in handleDocumentRequest.
if (shellRendered) {
console.error(error);
}
},
}
);

setTimeout(abort, ABORT_DELAY);
});
}

function handleBrowserRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
return new Promise((resolve, reject) => {
let shellRendered = false;
const { pipe, abort } = renderToPipeableStream(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
{
onShellReady() {
shellRendered = true;
const body = new PassThrough();

responseHeaders.set("Content-Type", "text/html");

resolve(
new Response(body, {
headers: responseHeaders,
status: responseStatusCode,
})
);

responseHeaders.set("Content-Type", "text/html");
pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
responseStatusCode = 500;
// Log streaming rendering errors from inside the shell. Don't log
// errors encountered during initial shell rendering since they'll
// reject and get logged in handleDocumentRequest.
if (shellRendered) {
console.error(error);
}
},
}
);

return new Response("<!DOCTYPE html>" + markup, {
status: responseStatusCode,
headers: responseHeaders,
setTimeout(abort, ABORT_DELAY);
});
}
File renamed without changes.
3 changes: 0 additions & 3 deletions app/lib/post/server/postService.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ export const getPostList = async (
user: User | null,
filters: PostFilters = {}
) => {
// https://github.com/planetscale/beam/issues/58
await prisma.$executeRaw`set sort_buffer_size=2097152`;

const blocks = await getBlockList(user);

const blockingMap = blocks.reduce((acc, block) => {
Expand Down
5 changes: 2 additions & 3 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ import {
getTheme,
} from "~/lib/core/server/session.server";
import { createMeta } from "~/lib/core/util/meta";

import knockStyles from "@knocklabs/react-notification-feed/dist/index.css";
import styles from "./tailwind.css";
import styles from "./global.css";

export const links: LinksFunction = () => [
{ rel: "stylesheet", href: knockStyles },
Expand Down Expand Up @@ -136,7 +135,7 @@ const App = () => {
<Outlet context={data} />
<ScrollRestoration />
<Scripts />
{process.env.NODE_ENV === "development" && <LiveReload />}
<LiveReload />
<ThemeBody ssrTheme={Boolean(data.theme)} />
<script
defer
Expand Down
Loading

1 comment on commit 51034e0

@vercel
Copy link

@vercel vercel bot commented on 51034e0 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

yours-sincerely – ./

yours-sincerely-git-main-kyh.vercel.app
yours-sincerely-kyh.vercel.app
www.yourssincerely.org
yourssincerely.org

Please sign in to comment.