Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getInstanceInfo } from './utils/litefs.server.ts'
import { NonceProvider } from './utils/nonce-provider.ts'
import { makeTimings } from './utils/timing.server.ts'

const ABORT_DELAY = 5000
export const streamTimeout = 5000

init()
global.ENV = getEnv()
Expand Down Expand Up @@ -53,7 +53,7 @@ export default async function handleRequest(...args: DocRequestArgs) {

const { pipe, abort } = renderToPipeableStream(
<NonceProvider value={nonce}>
<RemixServer context={remixContext} url={request.url} />
<RemixServer nonce={nonce} context={remixContext} url={request.url} />
</NonceProvider>,
{
[callbackName]: () => {
Expand All @@ -78,7 +78,7 @@ export default async function handleRequest(...args: DocRequestArgs) {
},
)

setTimeout(abort, ABORT_DELAY)
setTimeout(abort, streamTimeout + 5000)
})
}

Expand Down
7 changes: 4 additions & 3 deletions app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
json,
data,
type LoaderFunctionArgs,
type HeadersFunction,
type LinksFunction,
Expand Down Expand Up @@ -121,7 +121,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const { toast, headers: toastHeaders } = await getToast(request)
const honeyProps = honeypot.getInputProps()

return json(
return data(
{
user,
requestInfo: {
Expand Down Expand Up @@ -161,7 +161,8 @@ function Document({
children: React.ReactNode
nonce: string
theme?: Theme
env?: Record<string, string>
env?: Record<string, string | undefined>
allowIndexing?: boolean
}) {
const allowIndexing = ENV.ALLOW_INDEXING !== 'false'
return (
Expand Down
6 changes: 3 additions & 3 deletions app/routes/_auth+/forgot-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import * as E from '@react-email/components'
import {
json,
data,
redirect,
type ActionFunctionArgs,
type MetaFunction,
Expand Down Expand Up @@ -54,7 +54,7 @@ export async function action({ request }: ActionFunctionArgs) {
async: true,
})
if (submission.status !== 'success') {
return json(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down Expand Up @@ -84,7 +84,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (response.status === 'success') {
return redirect(redirectTo.toString())
} else {
return json(
return data(
{ result: submission.reply({ formErrors: [response.error.message] }) },
{ status: 500 },
)
Expand Down
6 changes: 3 additions & 3 deletions app/routes/_auth+/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
json,
data,
type ActionFunctionArgs,
type LoaderFunctionArgs,
type MetaFunction,
Expand Down Expand Up @@ -37,7 +37,7 @@ const LoginFormSchema = z.object({

export async function loader({ request }: LoaderFunctionArgs) {
await requireAnonymous(request)
return json({})
return {}
}

export async function action({ request }: ActionFunctionArgs) {
Expand All @@ -64,7 +64,7 @@ export async function action({ request }: ActionFunctionArgs) {
})

if (submission.status !== 'success' || !submission.value.session) {
return json(
return data(
{ result: submission.reply({ hideFields: ['password'] }) },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
6 changes: 3 additions & 3 deletions app/routes/_auth+/onboarding.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import {
json,
data,
redirect,
type LoaderFunctionArgs,
type ActionFunctionArgs,
Expand Down Expand Up @@ -61,7 +61,7 @@ async function requireOnboardingEmail(request: Request) {

export async function loader({ request }: LoaderFunctionArgs) {
const email = await requireOnboardingEmail(request)
return json({ email })
return { email }
}

export async function action({ request }: ActionFunctionArgs) {
Expand Down Expand Up @@ -93,7 +93,7 @@ export async function action({ request }: ActionFunctionArgs) {
})

if (submission.status !== 'success' || !submission.value.session) {
return json(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
8 changes: 4 additions & 4 deletions app/routes/_auth+/onboarding_.$provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import {
redirect,
json,
data,
type ActionFunctionArgs,
type LoaderFunctionArgs,
type MetaFunction,
Expand Down Expand Up @@ -95,15 +95,15 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const formError = connectionSession.get(authenticator.sessionErrorKey)
const hasError = typeof formError === 'string'

return json({
return {
email,
status: 'idle',
submission: {
status: hasError ? 'error' : undefined,
initialValue: prefilledProfile ?? {},
error: { '': hasError ? [formError] : [] },
} as SubmissionResult,
})
}
}

export async function action({ request, params }: ActionFunctionArgs) {
Expand Down Expand Up @@ -143,7 +143,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
})

if (submission.status !== 'success') {
return json(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_auth+/reset-password.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { invariant } from '@epic-web/invariant'
import { json, redirect } from '@remix-run/node'
import { data, redirect } from '@remix-run/node'
import { prisma } from '#app/utils/db.server.ts'
import { verifySessionStorage } from '#app/utils/verification.server.ts'
import { resetPasswordUsernameSessionKey } from './reset-password.tsx'
Expand All @@ -18,7 +18,7 @@ export async function handleVerification({ submission }: VerifyFunctionArgs) {
// we don't want to say the user is not found if the email is not found
// because that would allow an attacker to check if an email is registered
if (!user) {
return json(
return data(
{ result: submission.reply({ fieldErrors: { code: ['Invalid code'] } }) },
{ status: 400 },
)
Expand Down
6 changes: 3 additions & 3 deletions app/routes/_auth+/reset-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getFormProps, getInputProps, useForm } from '@conform-to/react'
import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
json,
data,
redirect,
type ActionFunctionArgs,
type LoaderFunctionArgs,
Expand Down Expand Up @@ -41,7 +41,7 @@ async function requireResetPasswordUsername(request: Request) {

export async function loader({ request }: LoaderFunctionArgs) {
const resetPasswordUsername = await requireResetPasswordUsername(request)
return json({ resetPasswordUsername })
return { resetPasswordUsername }
}

export async function action({ request }: ActionFunctionArgs) {
Expand All @@ -51,7 +51,7 @@ export async function action({ request }: ActionFunctionArgs) {
schema: ResetPasswordSchema,
})
if (submission.status !== 'success') {
return json(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
6 changes: 3 additions & 3 deletions app/routes/_auth+/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getZodConstraint, parseWithZod } from '@conform-to/zod'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import * as E from '@react-email/components'
import {
json,
data,
redirect,
type ActionFunctionArgs,
type MetaFunction,
Expand Down Expand Up @@ -56,7 +56,7 @@ export async function action({ request }: ActionFunctionArgs) {
async: true,
})
if (submission.status !== 'success') {
return json(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand All @@ -78,7 +78,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (response.status === 'success') {
return redirect(redirectTo.toString())
} else {
return json(
return data(
{
result: submission.reply({ formErrors: [response.error.message] }),
},
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_auth+/verify.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Submission } from '@conform-to/react'
import { parseWithZod } from '@conform-to/zod'
import { json } from '@remix-run/node'
import { data } from '@remix-run/node'
import { z } from 'zod'
import { handleVerification as handleChangeEmailVerification } from '#app/routes/settings+/profile.change-email.server.tsx'
import { twoFAVerificationType } from '#app/routes/settings+/profile.two-factor.tsx'
Expand Down Expand Up @@ -161,7 +161,7 @@ export async function validateRequest(
})

if (submission.status !== 'success') {
return json(
return data(
{ result: submission.reply() },
{ status: submission.status === 'error' ? 400 : 200 },
)
Expand Down
5 changes: 2 additions & 3 deletions app/routes/admin+/cache.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { invariantResponse } from '@epic-web/invariant'
import { type SEOHandle } from '@nasa-gcn/remix-seo'
import {
json,
redirect,
type LoaderFunctionArgs,
type ActionFunctionArgs,
Expand Down Expand Up @@ -58,7 +57,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
} else {
cacheKeys = await getAllCacheKeys(limit)
}
return json({ cacheKeys, instance, instances, currentInstanceInfo })
return { cacheKeys, instance, instances, currentInstanceInfo }
}

export async function action({ request }: ActionFunctionArgs) {
Expand Down Expand Up @@ -87,7 +86,7 @@ export async function action({ request }: ActionFunctionArgs) {
throw new Error(`Unknown cache type: ${type}`)
}
}
return json({ success: true })
return { success: true }
}

export default function CacheAdminRoute() {
Expand Down
6 changes: 3 additions & 3 deletions app/routes/admin+/cache_.lru.$cacheKey.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { invariantResponse } from '@epic-web/invariant'
import { json, type LoaderFunctionArgs } from '@remix-run/node'
import { type LoaderFunctionArgs } from '@remix-run/node'
import { lruCache } from '#app/utils/cache.server.ts'
import {
getAllInstances,
Expand All @@ -19,13 +19,13 @@ export async function loader({ request, params }: LoaderFunctionArgs) {

const { cacheKey } = params
invariantResponse(cacheKey, 'cacheKey is required')
return json({
return {
instance: {
hostname: instance,
region: allInstances[instance],
isPrimary: currentInstanceInfo.primaryInstance === instance,
},
cacheKey,
value: lruCache.get(cacheKey),
})
}
}
6 changes: 3 additions & 3 deletions app/routes/admin+/cache_.sqlite.$cacheKey.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { invariantResponse } from '@epic-web/invariant'
import { json, type LoaderFunctionArgs } from '@remix-run/node'
import { type LoaderFunctionArgs } from '@remix-run/node'
import { cache } from '#app/utils/cache.server.ts'
import {
getAllInstances,
Expand All @@ -19,13 +19,13 @@ export async function loader({ request, params }: LoaderFunctionArgs) {

const { cacheKey } = params
invariantResponse(cacheKey, 'cacheKey is required')
return json({
return {
instance: {
hostname: instance,
region: allInstances[instance],
isPrimary: currentInstanceInfo.primaryInstance === instance,
},
cacheKey,
value: cache.get(cacheKey),
})
}
}
4 changes: 2 additions & 2 deletions app/routes/admin+/cache_.sqlite.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { json, redirect, type ActionFunctionArgs } from '@remix-run/node'
import { redirect, type ActionFunctionArgs } from '@remix-run/node'
import { z } from 'zod'
import { cache } from '#app/utils/cache.server.ts'
import {
Expand Down Expand Up @@ -54,5 +54,5 @@ export async function action({ request }: ActionFunctionArgs) {
// @ts-expect-error - we don't reliably know the type of cacheValue
await cache.set(key, cacheValue)
}
return json({ success: true })
return { success: true }
}
4 changes: 2 additions & 2 deletions app/routes/resources+/theme-switch.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useForm, getFormProps } from '@conform-to/react'
import { parseWithZod } from '@conform-to/zod'
import { invariantResponse } from '@epic-web/invariant'
import { json, type ActionFunctionArgs } from '@remix-run/node'
import { data, type ActionFunctionArgs } from '@remix-run/node'
import { redirect, useFetcher, useFetchers } from '@remix-run/react'
import { ServerOnly } from 'remix-utils/server-only'
import { z } from 'zod'
Expand Down Expand Up @@ -35,7 +35,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (redirectTo) {
return redirect(redirectTo, responseInit)
} else {
return json({ result: submission.reply() }, responseInit)
return data({ result: submission.reply() }, responseInit)
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/routes/settings+/profile.change-email.server.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { invariant } from '@epic-web/invariant'
import * as E from '@react-email/components'
import { json } from '@remix-run/node'
import { data } from '@remix-run/node'
import {
requireRecentVerification,
type VerifyFunctionArgs,
Expand All @@ -26,7 +26,7 @@ export async function handleVerification({
)
const newEmail = verifySession.get(newEmailAddressSessionKey)
if (!newEmail) {
return json(
return data(
{
result: submission.reply({
formErrors: [
Expand Down
Loading