diff --git a/app/root.tsx b/app/root.tsx index cec03914..2f20d19d 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -1,5 +1,5 @@ import { - data as dataResponse, + data, type LoaderFunctionArgs, type HeadersFunction, type LinksFunction, @@ -117,7 +117,7 @@ export async function loader({ request }: LoaderFunctionArgs) { const { toast, headers: toastHeaders } = await getToast(request) const honeyProps = honeypot.getInputProps() - return dataResponse( + return data( { user, requestInfo: { diff --git a/app/routes/_auth+/forgot-password.tsx b/app/routes/_auth+/forgot-password.tsx index 2743ca01..285f1fa8 100644 --- a/app/routes/_auth+/forgot-password.tsx +++ b/app/routes/_auth+/forgot-password.tsx @@ -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 { - data as dataResponse, + data, redirect, type ActionFunctionArgs, type MetaFunction, @@ -54,7 +54,7 @@ export async function action({ request }: ActionFunctionArgs) { async: true, }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) @@ -84,7 +84,7 @@ export async function action({ request }: ActionFunctionArgs) { if (response.status === 'success') { return redirect(redirectTo.toString()) } else { - return dataResponse( + return data( { result: submission.reply({ formErrors: [response.error.message] }) }, { status: 500 }, ) diff --git a/app/routes/_auth+/login.tsx b/app/routes/_auth+/login.tsx index 259caf1c..14810f63 100644 --- a/app/routes/_auth+/login.tsx +++ b/app/routes/_auth+/login.tsx @@ -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 { - data as dataResponse, + data, type ActionFunctionArgs, type LoaderFunctionArgs, type MetaFunction, @@ -64,7 +64,7 @@ export async function action({ request }: ActionFunctionArgs) { }) if (submission.status !== 'success' || !submission.value.session) { - return dataResponse( + return data( { result: submission.reply({ hideFields: ['password'] }) }, { status: submission.status === 'error' ? 400 : 200 }, ) diff --git a/app/routes/_auth+/onboarding.tsx b/app/routes/_auth+/onboarding.tsx index f42550ef..a087363f 100644 --- a/app/routes/_auth+/onboarding.tsx +++ b/app/routes/_auth+/onboarding.tsx @@ -1,7 +1,7 @@ import { getFormProps, getInputProps, useForm } from '@conform-to/react' import { getZodConstraint, parseWithZod } from '@conform-to/zod' import { - data as dataResponse, + data, redirect, type LoaderFunctionArgs, type ActionFunctionArgs, @@ -93,7 +93,7 @@ export async function action({ request }: ActionFunctionArgs) { }) if (submission.status !== 'success' || !submission.value.session) { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) diff --git a/app/routes/_auth+/onboarding_.$provider.tsx b/app/routes/_auth+/onboarding_.$provider.tsx index e85018c4..46f5cc98 100644 --- a/app/routes/_auth+/onboarding_.$provider.tsx +++ b/app/routes/_auth+/onboarding_.$provider.tsx @@ -7,7 +7,7 @@ import { import { getZodConstraint, parseWithZod } from '@conform-to/zod' import { redirect, - data as dataResponse, + data, type ActionFunctionArgs, type LoaderFunctionArgs, type MetaFunction, @@ -143,7 +143,7 @@ export async function action({ request, params }: ActionFunctionArgs) { }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) diff --git a/app/routes/_auth+/reset-password.server.ts b/app/routes/_auth+/reset-password.server.ts index 86f6e92d..39c4caa8 100644 --- a/app/routes/_auth+/reset-password.server.ts +++ b/app/routes/_auth+/reset-password.server.ts @@ -1,5 +1,5 @@ import { invariant } from '@epic-web/invariant' -import { data as dataResponse, 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' @@ -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 dataResponse( + return data( { result: submission.reply({ fieldErrors: { code: ['Invalid code'] } }) }, { status: 400 }, ) diff --git a/app/routes/_auth+/reset-password.tsx b/app/routes/_auth+/reset-password.tsx index 6bf0a66b..a78e3057 100644 --- a/app/routes/_auth+/reset-password.tsx +++ b/app/routes/_auth+/reset-password.tsx @@ -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 { - data as dataResponse, + data, redirect, type ActionFunctionArgs, type LoaderFunctionArgs, @@ -51,7 +51,7 @@ export async function action({ request }: ActionFunctionArgs) { schema: ResetPasswordSchema, }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) diff --git a/app/routes/_auth+/signup.tsx b/app/routes/_auth+/signup.tsx index 7fbf3242..ea65f559 100644 --- a/app/routes/_auth+/signup.tsx +++ b/app/routes/_auth+/signup.tsx @@ -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 { - data as dataResponse, + data, redirect, type ActionFunctionArgs, type MetaFunction, @@ -56,7 +56,7 @@ export async function action({ request }: ActionFunctionArgs) { async: true, }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) @@ -78,7 +78,7 @@ export async function action({ request }: ActionFunctionArgs) { if (response.status === 'success') { return redirect(redirectTo.toString()) } else { - return dataResponse( + return data( { result: submission.reply({ formErrors: [response.error.message] }), }, diff --git a/app/routes/_auth+/verify.server.ts b/app/routes/_auth+/verify.server.ts index 710b5cc4..337df0d1 100644 --- a/app/routes/_auth+/verify.server.ts +++ b/app/routes/_auth+/verify.server.ts @@ -1,6 +1,6 @@ import { type Submission } from '@conform-to/react' import { parseWithZod } from '@conform-to/zod' -import { data as dataResponse } 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' @@ -161,7 +161,7 @@ export async function validateRequest( }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) diff --git a/app/routes/resources+/theme-switch.tsx b/app/routes/resources+/theme-switch.tsx index 9b6f9c11..21a165ce 100644 --- a/app/routes/resources+/theme-switch.tsx +++ b/app/routes/resources+/theme-switch.tsx @@ -1,7 +1,7 @@ import { useForm, getFormProps } from '@conform-to/react' import { parseWithZod } from '@conform-to/zod' import { invariantResponse } from '@epic-web/invariant' -import { data as dataResponse, 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' @@ -32,7 +32,7 @@ export async function action({ request }: ActionFunctionArgs) { if (redirectTo) { return redirect(redirectTo, responseInit) } else { - return dataResponse({ result: submission.reply() }, responseInit) + return data({ result: submission.reply() }, responseInit) } } diff --git a/app/routes/settings+/profile.change-email.server.tsx b/app/routes/settings+/profile.change-email.server.tsx index acdc9965..675cc617 100644 --- a/app/routes/settings+/profile.change-email.server.tsx +++ b/app/routes/settings+/profile.change-email.server.tsx @@ -1,6 +1,6 @@ import { invariant } from '@epic-web/invariant' import * as E from '@react-email/components' -import { data as dataResponse } from '@remix-run/node' +import { data } from '@remix-run/node' import { requireRecentVerification, type VerifyFunctionArgs, @@ -26,7 +26,7 @@ export async function handleVerification({ ) const newEmail = verifySession.get(newEmailAddressSessionKey) if (!newEmail) { - return dataResponse( + return data( { result: submission.reply({ formErrors: [ diff --git a/app/routes/settings+/profile.change-email.tsx b/app/routes/settings+/profile.change-email.tsx index e7346307..00893a93 100644 --- a/app/routes/settings+/profile.change-email.tsx +++ b/app/routes/settings+/profile.change-email.tsx @@ -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 { - data as dataResponse, + data, redirect, type ActionFunctionArgs, type LoaderFunctionArgs, @@ -70,7 +70,7 @@ export async function action({ request }: ActionFunctionArgs) { }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) @@ -97,7 +97,7 @@ export async function action({ request }: ActionFunctionArgs) { }, }) } else { - return dataResponse( + return data( { result: submission.reply({ formErrors: [response.error.message] }) }, { status: 500 }, ) diff --git a/app/routes/settings+/profile.connections.tsx b/app/routes/settings+/profile.connections.tsx index 4255bdb9..d0f48ef5 100644 --- a/app/routes/settings+/profile.connections.tsx +++ b/app/routes/settings+/profile.connections.tsx @@ -1,7 +1,7 @@ import { invariantResponse } from '@epic-web/invariant' import { type SEOHandle } from '@nasa-gcn/remix-seo' import { - data as dataResponse, + data, type LoaderFunctionArgs, type ActionFunctionArgs, type SerializeFrom, @@ -81,7 +81,7 @@ export async function loader({ request }: LoaderFunctionArgs) { }) } - return dataResponse( + return data( { connections, canDeleteConnections: await userCanDeleteConnections(userId), @@ -120,7 +120,7 @@ export async function action({ request }: ActionFunctionArgs) { title: 'Deleted', description: 'Your connection has been deleted.', }) - return dataResponse({ status: 'success' } as const, { headers: toastHeaders }) + return data({ status: 'success' } as const, { headers: toastHeaders }) } export default function Connections() { diff --git a/app/routes/settings+/profile.index.tsx b/app/routes/settings+/profile.index.tsx index 21b479c1..f3b91b1c 100644 --- a/app/routes/settings+/profile.index.tsx +++ b/app/routes/settings+/profile.index.tsx @@ -3,7 +3,7 @@ import { getZodConstraint, parseWithZod } from '@conform-to/zod' import { invariantResponse } from '@epic-web/invariant' import { type SEOHandle } from '@nasa-gcn/remix-seo' import { - data as dataResponse, + data, type LoaderFunctionArgs, type ActionFunctionArgs, } from '@remix-run/node' @@ -194,7 +194,7 @@ async function profileUpdateAction({ userId, formData }: ProfileActionArgs) { }), }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) diff --git a/app/routes/settings+/profile.password.tsx b/app/routes/settings+/profile.password.tsx index 99a5f176..f239936a 100644 --- a/app/routes/settings+/profile.password.tsx +++ b/app/routes/settings+/profile.password.tsx @@ -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 { - data as dataResponse, + data, redirect, type LoaderFunctionArgs, type ActionFunctionArgs, @@ -83,7 +83,7 @@ export async function action({ request }: ActionFunctionArgs) { ), }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply({ hideFields: ['currentPassword', 'newPassword', 'confirmNewPassword'], diff --git a/app/routes/settings+/profile.password_.create.tsx b/app/routes/settings+/profile.password_.create.tsx index d1b7c104..ff4bba61 100644 --- a/app/routes/settings+/profile.password_.create.tsx +++ b/app/routes/settings+/profile.password_.create.tsx @@ -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 { - data as dataResponse, + data, redirect, type LoaderFunctionArgs, type ActionFunctionArgs, @@ -50,7 +50,7 @@ export async function action({ request }: ActionFunctionArgs) { schema: CreatePasswordForm, }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply({ hideFields: ['password', 'confirmPassword'], diff --git a/app/routes/settings+/profile.photo.tsx b/app/routes/settings+/profile.photo.tsx index f731d7c8..8b083981 100644 --- a/app/routes/settings+/profile.photo.tsx +++ b/app/routes/settings+/profile.photo.tsx @@ -3,7 +3,7 @@ import { getZodConstraint, parseWithZod } from '@conform-to/zod' import { invariantResponse } from '@epic-web/invariant' import { type SEOHandle } from '@nasa-gcn/remix-seo' import { - data as dataResponse, + data, redirect, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData, @@ -96,7 +96,7 @@ export async function action({ request }: ActionFunctionArgs) { }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) diff --git a/app/routes/settings+/profile.two-factor.verify.tsx b/app/routes/settings+/profile.two-factor.verify.tsx index 002e99ed..a8e7f438 100644 --- a/app/routes/settings+/profile.two-factor.verify.tsx +++ b/app/routes/settings+/profile.two-factor.verify.tsx @@ -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 { - data as dataResponse, + data, redirect, type LoaderFunctionArgs, type ActionFunctionArgs, @@ -102,7 +102,7 @@ export async function action({ request }: ActionFunctionArgs) { }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) diff --git a/app/routes/users+/$username_+/__note-editor.server.tsx b/app/routes/users+/$username_+/__note-editor.server.tsx index 2a1b2315..0ccc5410 100644 --- a/app/routes/users+/$username_+/__note-editor.server.tsx +++ b/app/routes/users+/$username_+/__note-editor.server.tsx @@ -2,7 +2,7 @@ import { parseWithZod } from '@conform-to/zod' import { createId as cuid } from '@paralleldrive/cuid2' import { unstable_createMemoryUploadHandler as createMemoryUploadHandler, - data as dataResponse, + data, unstable_parseMultipartFormData as parseMultipartFormData, redirect, type ActionFunctionArgs, @@ -88,7 +88,7 @@ export async function action({ request }: ActionFunctionArgs) { }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) diff --git a/app/routes/users+/$username_+/notes.$noteId.tsx b/app/routes/users+/$username_+/notes.$noteId.tsx index 624be37b..54cd0bd6 100644 --- a/app/routes/users+/$username_+/notes.$noteId.tsx +++ b/app/routes/users+/$username_+/notes.$noteId.tsx @@ -2,7 +2,7 @@ import { getFormProps, useForm } from '@conform-to/react' import { parseWithZod } from '@conform-to/zod' import { invariantResponse } from '@epic-web/invariant' import { - data as dataResponse, + data, type LoaderFunctionArgs, type ActionFunctionArgs, } from '@remix-run/node' @@ -67,7 +67,7 @@ export async function action({ request }: ActionFunctionArgs) { schema: DeleteFormSchema, }) if (submission.status !== 'success') { - return dataResponse( + return data( { result: submission.reply() }, { status: submission.status === 'error' ? 400 : 200 }, ) diff --git a/app/routes/users+/index.tsx b/app/routes/users+/index.tsx index 5022cdd7..7c321af6 100644 --- a/app/routes/users+/index.tsx +++ b/app/routes/users+/index.tsx @@ -1,8 +1,4 @@ -import { - data as dataResponse, - redirect, - type LoaderFunctionArgs, -} from '@remix-run/node' +import { data, redirect, type LoaderFunctionArgs } from '@remix-run/node' import { Link, useLoaderData } from '@remix-run/react' import { z } from 'zod' import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx' @@ -45,10 +41,9 @@ export async function loader({ request }: LoaderFunctionArgs) { const result = UserSearchResultsSchema.safeParse(rawUsers) if (!result.success) { - return dataResponse( - { status: 'error', error: result.error.message } as const, - { status: 400 }, - ) + return data({ status: 'error', error: result.error.message } as const, { + status: 400, + }) } return { status: 'idle', users: result.data } as const } diff --git a/app/utils/permissions.server.ts b/app/utils/permissions.server.ts index 55b569d4..74aa5aa8 100644 --- a/app/utils/permissions.server.ts +++ b/app/utils/permissions.server.ts @@ -1,4 +1,4 @@ -import { data as dataResponse } from '@remix-run/node' +import { data } from '@remix-run/node' import { requireUserId } from './auth.server.ts' import { prisma } from './db.server.ts' import { type PermissionString, parsePermissionString } from './user.ts' @@ -28,7 +28,7 @@ export async function requireUserWithPermission( }, }) if (!user) { - throw dataResponse( + throw data( { error: 'Unauthorized', requiredPermission: permissionData, @@ -47,7 +47,7 @@ export async function requireUserWithRole(request: Request, name: string) { where: { id: userId, roles: { some: { name } } }, }) if (!user) { - throw dataResponse( + throw data( { error: 'Unauthorized', requiredRole: name,