Skip to content

Commit

Permalink
upgrade to remix v2
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Sep 16, 2023
1 parent 9566382 commit 25032f3
Show file tree
Hide file tree
Showing 46 changed files with 4,816 additions and 4,787 deletions.
11 changes: 7 additions & 4 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {Response, type HandleDocumentRequestFunction} from '@remix-run/node'
import {
createReadableStreamFromReadable,
type HandleDocumentRequestFunction,
} from '@remix-run/node'
import {RemixServer} from '@remix-run/react'
import isbot from 'isbot'
import {ensurePrimary} from 'litefs-js/remix.js'
import {ensurePrimary} from '~/utils/cjs/litefs-js.server.js'
import {renderToPipeableStream} from 'react-dom/server'
import {PassThrough, Transform} from 'stream'
import {routes as otherRoutes} from './other-routes.server.ts'
Expand Down Expand Up @@ -106,7 +109,7 @@ function serveTheBots(...args: DocRequestArgs) {

stream.pipe(dataEvtTransform).pipe(body)
resolve(
new Response(body, {
new Response(createReadableStreamFromReadable(body), {
status: responseStatusCode,
headers: responseHeaders,
}),
Expand Down Expand Up @@ -160,7 +163,7 @@ function serveBrowsers(...args: DocRequestArgs) {

stream.pipe(dataEvtTransform).pipe(body)
resolve(
new Response(body, {
new Response(createReadableStreamFromReadable(body), {
status: didError ? 500 : responseStatusCode,
headers: responseHeaders,
}),
Expand Down
13 changes: 9 additions & 4 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type DataFunctionArgs,
type HeadersFunction,
type LinksFunction,
type V2_MetaFunction,
type MetaFunction,
type SerializeFrom,
} from '@remix-run/node'
import {
Expand All @@ -27,7 +27,7 @@ import {MetronomeLinks} from '@metronome-sh/react'
import {clsx} from 'clsx'
import {isFuture} from 'date-fns'
import {AnimatePresence, motion} from 'framer-motion'
import {getInstanceInfo} from '~/utils/cjs/litefs-js.js'
import {getInstanceInfo} from '~/utils/cjs/litefs-js.server.js'
import {useSpinDelay} from 'spin-delay'
import {type KCDHandle} from '~/types.ts'
import {ArrowLink} from './components/arrow-button.tsx'
Expand Down Expand Up @@ -80,7 +80,7 @@ export const handle: KCDHandle & {id: string} = {
id: 'root',
}

export const meta: V2_MetaFunction<typeof loader> = ({data}) => {
export const meta: MetaFunction<typeof loader> = ({data}) => {
const requestInfo = data?.requestInfo
const title = 'Kent C. Dodds'
const description =
Expand Down Expand Up @@ -562,7 +562,12 @@ export default function AppWithProviders() {
const data = useLoaderData<LoaderData>()
return (
<TeamProvider>
<ThemeProvider specifiedTheme={data.requestInfo.session.theme}>
<ThemeProvider
specifiedTheme={
// @ts-expect-error I've really gotta use the epic stack's theme stuff...
data.requestInfo.session.theme
}
>
<App />
</ThemeProvider>
</TeamProvider>
Expand Down
3 changes: 1 addition & 2 deletions app/routes/$slug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
json,
type DataFunctionArgs,
type HeadersFunction,
type V2_MetaFunction,
} from '@remix-run/node'
import {
isRouteErrorResponse,
Expand Down Expand Up @@ -71,7 +70,7 @@ export async function loader({params, request}: DataFunctionArgs) {

export const headers: HeadersFunction = reuseUsefulLoaderHeaders

export const meta: V2_MetaFunction = mdxPageMeta
export const meta = mdxPageMeta

export default function MdxScreen() {
const data = useLoaderData<typeof loader>()
Expand Down
4 changes: 2 additions & 2 deletions app/routes/404.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {type V2_MetaFunction} from '@remix-run/node'
import {type MetaFunction} from '@remix-run/node'
import {HeroSection} from '~/components/sections/hero-section.tsx'
import {images} from '~/images.tsx'
import {type KCDHandle} from '~/types.ts'
Expand All @@ -7,7 +7,7 @@ export const handle: KCDHandle = {
getSitemapEntries: () => null,
}

export const meta: V2_MetaFunction = () => {
export const meta: MetaFunction = () => {
return [{title: "Ain't nothing here"}]
}

Expand Down
4 changes: 2 additions & 2 deletions app/routes/about.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
type HeadersFunction,
type LinksFunction,
type LoaderFunction,
type V2_MetaFunction,
type MetaFunction,
} from '@remix-run/node'
import {useLoaderData, useSearchParams} from '@remix-run/react'
import {shuffle} from '~/utils/cjs/lodash.js'
Expand Down Expand Up @@ -62,7 +62,7 @@ export const loader: LoaderFunction = async ({request}) => {

export const headers: HeadersFunction = reuseUsefulLoaderHeaders

export const meta: V2_MetaFunction<typeof loader, {root: RootLoaderType}> = ({
export const meta: MetaFunction<typeof loader, {root: RootLoaderType}> = ({
matches,
}) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
Expand Down
2 changes: 1 addition & 1 deletion app/routes/action+/refresh-cache.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {json, redirect, type DataFunctionArgs} from '@remix-run/node'
import {ensurePrimary} from 'litefs-js/remix.js'
import {ensurePrimary} from '~/utils/cjs/litefs-js.server.js'
import path from 'path'
import {cache} from '~/utils/cache.server.ts'
import {getPeople} from '~/utils/credits.server.ts'
Expand Down
4 changes: 2 additions & 2 deletions app/routes/blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type DataFunctionArgs,
type HeadersFunction,
type LinksFunction,
type V2_MetaFunction,
type MetaFunction,
type SerializeFrom,
} from '@remix-run/node'
import {
Expand Down Expand Up @@ -128,7 +128,7 @@ export async function loader({request}: DataFunctionArgs) {

export const headers: HeadersFunction = reuseUsefulLoaderHeaders

export const meta: V2_MetaFunction<typeof loader, {root: RootLoaderType}> = ({
export const meta: MetaFunction<typeof loader, {root: RootLoaderType}> = ({
data,
matches,
}) => {
Expand Down
3 changes: 1 addition & 2 deletions app/routes/blog_+/$slug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
json,
type DataFunctionArgs,
type HeadersFunction,
type V2_MetaFunction,
} from '@remix-run/node'
import {
isRouteErrorResponse,
Expand Down Expand Up @@ -221,7 +220,7 @@ export async function loader({request, params}: DataFunctionArgs) {

export const headers: HeadersFunction = reuseUsefulLoaderHeaders

export const meta: V2_MetaFunction = mdxPageMeta
export const meta = mdxPageMeta

function useOnRead({
parentElRef,
Expand Down
7 changes: 5 additions & 2 deletions app/routes/cache.admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import {
useSearchParams,
useSubmit,
} from '@remix-run/react'
import {getAllInstances, getInstanceInfo} from '~/utils/cjs/litefs-js.js'
import {ensureInstance} from 'litefs-js/remix.js'
import {
ensureInstance,
getAllInstances,
getInstanceInfo,
} from '~/utils/cjs/litefs-js.server.js'
import invariant from 'tiny-invariant'
import {Button} from '~/components/button.tsx'
import {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/calls+/$season.$episode_.$slug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
redirect,
type HeadersFunction,
type LoaderFunction,
type V2_MetaFunction,
type MetaFunction,
} from '@remix-run/node'
import {useParams} from '@remix-run/react'
import {IconLink} from '~/components/icon-link.tsx'
Expand Down Expand Up @@ -46,7 +46,7 @@ export const handle: KCDHandle = {
},
}

export const meta: V2_MetaFunction<
export const meta: MetaFunction<
typeof loader,
{root: RootLoaderType; 'routes/calls': typeof callsLoader}
> = ({matches, params}) => {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/calls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
json,
type HeadersFunction,
type LoaderFunction,
type V2_MetaFunction,
type MetaFunction,
} from '@remix-run/node'
import {
Link,
Expand Down Expand Up @@ -100,7 +100,7 @@ export const loader: LoaderFunction = async ({request}) => {

export const headers: HeadersFunction = reuseUsefulLoaderHeaders

export const meta: V2_MetaFunction<typeof loader, {root: RootLoaderType}> = ({
export const meta: MetaFunction<typeof loader, {root: RootLoaderType}> = ({
matches,
}) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
Expand Down
4 changes: 2 additions & 2 deletions app/routes/chats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
json,
type HeadersFunction,
type LoaderFunction,
type V2_MetaFunction,
type MetaFunction,
} from '@remix-run/node'
import {
Link,
Expand Down Expand Up @@ -71,7 +71,7 @@ export const loader: LoaderFunction = async ({request}) => {

export const headers: HeadersFunction = reuseUsefulLoaderHeaders

export const meta: V2_MetaFunction<typeof loader, {root: RootLoaderType}> = ({
export const meta: MetaFunction<typeof loader, {root: RootLoaderType}> = ({
data,
matches,
}) => {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/chats_+/$season.$episode_.$slug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
redirect,
type HeadersFunction,
type LoaderFunction,
type V2_MetaFunction,
type MetaFunction,
} from '@remix-run/node'
import {
isRouteErrorResponse,
Expand Down Expand Up @@ -69,7 +69,7 @@ export const handle: KCDHandle = {
},
}

export const meta: V2_MetaFunction<typeof loader, {root: RootLoaderType}> = ({
export const meta: MetaFunction<typeof loader, {root: RootLoaderType}> = ({
data,
matches,
}) => {
Expand Down
12 changes: 5 additions & 7 deletions app/routes/contact.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
json,
type ActionFunction,
type HeadersFunction,
type V2_MetaFunction,
type MetaFunction,
type DataFunctionArgs,
} from '@remix-run/node'
import {Link, useFetcher} from '@remix-run/react'
import {Button} from '~/components/button.tsx'
Expand Down Expand Up @@ -49,7 +49,7 @@ type ActionData = {
}
}

export const action: ActionFunction = async ({request}) => {
export const action = async ({request}: DataFunctionArgs) => {
const user = await requireUser(request)
return handleFormSubmission<ActionData>({
request,
Expand Down Expand Up @@ -84,9 +84,7 @@ export const headers: HeadersFunction = () => ({
Vary: 'Cookie',
})

export const meta: V2_MetaFunction<{}, {root: RootLoaderType}> = ({
matches,
}) => {
export const meta: MetaFunction<{}, {root: RootLoaderType}> = ({matches}) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const requestInfo = matches.find(m => m.id === 'root')?.data.requestInfo
return getSocialMetas({
Expand All @@ -102,7 +100,7 @@ export const meta: V2_MetaFunction<{}, {root: RootLoaderType}> = ({
}

export default function ContactRoute() {
const contactFetcher = useFetcher()
const contactFetcher = useFetcher<typeof action>()
const {user} = useRootData()

const isDone = contactFetcher.state === 'idle' && contactFetcher.data != null
Expand Down
4 changes: 2 additions & 2 deletions app/routes/courses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
json,
type HeadersFunction,
type LoaderFunction,
type V2_MetaFunction,
type MetaFunction,
} from '@remix-run/node'
import {Link, useLoaderData} from '@remix-run/react'
import {ArrowLink} from '~/components/arrow-button.tsx'
Expand Down Expand Up @@ -42,7 +42,7 @@ export const loader: LoaderFunction = async ({request}) => {

export const headers: HeadersFunction = reuseUsefulLoaderHeaders

export const meta: V2_MetaFunction<typeof loader, {root: RootLoaderType}> = ({
export const meta: MetaFunction<typeof loader, {root: RootLoaderType}> = ({
matches,
}) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
Expand Down
4 changes: 2 additions & 2 deletions app/routes/credits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
json,
type HeadersFunction,
type LoaderFunction,
type V2_MetaFunction,
type MetaFunction,
} from '@remix-run/node'
import {useLoaderData} from '@remix-run/react'
import {shuffle} from '~/utils/cjs/lodash.js'
Expand Down Expand Up @@ -59,7 +59,7 @@ export const loader: LoaderFunction = async ({request}) => {

export const headers: HeadersFunction = reuseUsefulLoaderHeaders

export const meta: V2_MetaFunction<typeof loader, {root: RootLoaderType}> = ({
export const meta: MetaFunction<typeof loader, {root: RootLoaderType}> = ({
matches,
}) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
Expand Down
2 changes: 1 addition & 1 deletion app/routes/discord+/callback.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {defer, redirect, type DataFunctionArgs} from '@remix-run/node'
import {Await, Link, useAsyncError, useLoaderData} from '@remix-run/react'
import {ensurePrimary} from 'litefs-js/remix.js'
import {ensurePrimary} from '~/utils/cjs/litefs-js.server.js'
import React, {Suspense} from 'react'
import {ArrowLink} from '~/components/arrow-button.tsx'
import {ErrorPanel} from '~/components/form-elements.tsx'
Expand Down
4 changes: 2 additions & 2 deletions app/routes/discord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
json,
type HeadersFunction,
type LoaderFunction,
type V2_MetaFunction,
type MetaFunction,
} from '@remix-run/node'
import {Outlet, useLoaderData, useRouteError} from '@remix-run/react'
import {motion} from 'framer-motion'
Expand Down Expand Up @@ -75,7 +75,7 @@ export const loader: LoaderFunction = async ({request}) => {

export const headers: HeadersFunction = reuseUsefulLoaderHeaders

export const meta: V2_MetaFunction<typeof loader, {root: RootLoaderType}> = ({
export const meta: MetaFunction<typeof loader, {root: RootLoaderType}> = ({
matches,
}) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
Expand Down
4 changes: 2 additions & 2 deletions app/routes/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type ActionFunction,
type HeadersFunction,
type LoaderFunction,
type V2_MetaFunction,
type MetaFunction,
} from '@remix-run/node'
import {Form, useLoaderData} from '@remix-run/react'
import * as React from 'react'
Expand Down Expand Up @@ -58,7 +58,7 @@ export const loader: LoaderFunction = async ({request}) => {

export const headers: HeadersFunction = reuseUsefulLoaderHeaders

export const meta: V2_MetaFunction<typeof loader, {root: RootLoaderType}> = ({
export const meta: MetaFunction<typeof loader, {root: RootLoaderType}> = ({
matches,
}) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
Expand Down
2 changes: 1 addition & 1 deletion app/routes/magic.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {redirect, type DataFunctionArgs} from '@remix-run/node'
import {type KCDHandle} from '~/types.ts'

import {ensurePrimary} from 'litefs-js/remix.js'
import {ensurePrimary} from '~/utils/cjs/litefs-js.server.js'
import {getClientSession} from '~/utils/client.server.ts'
import {getLoginInfoSession} from '~/utils/login.server.ts'
import {getErrorMessage, isResponse} from '~/utils/misc.tsx'
Expand Down
4 changes: 2 additions & 2 deletions app/routes/me+/_me.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type ActionFunction,
type DataFunctionArgs,
type HeadersFunction,
type V2_MetaFunction,
type MetaFunction,
} from '@remix-run/node'
import {Form, useActionData, useLoaderData} from '@remix-run/react'
import {clsx} from 'clsx'
Expand Down Expand Up @@ -61,7 +61,7 @@ export const handle: KCDHandle = {
getSitemapEntries: () => null,
}

export const meta: V2_MetaFunction<typeof loader, {root: RootLoaderType}> = ({
export const meta: MetaFunction<typeof loader, {root: RootLoaderType}> = ({
matches,
}) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
Expand Down
Loading

0 comments on commit 25032f3

Please sign in to comment.