Skip to content

Commit

Permalink
chore: adpot remix react router 7 future flags (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpedroh authored Dec 29, 2024
1 parent d3efae4 commit 1c2919d
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 15 deletions.
3 changes: 3 additions & 0 deletions apps/web/app/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { flatRoutes } from '@remix-run/fs-routes'

export default flatRoutes()
8 changes: 4 additions & 4 deletions apps/web/app/routes/api.flights.$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { makeDatabaseConnection } from '@mach/shared-database'
import {
type HeadersFunction,
LoaderFunctionArgs,
json,
data,
} from '@remix-run/cloudflare'
import * as Sentry from '@sentry/remix'
import { fetchFlightById } from '../services/fetch-flight-by-id'
Expand All @@ -18,11 +18,11 @@ export async function loader({ params, context }: LoaderFunctionArgs) {
const db = makeDatabaseConnection(context)
const flight = await fetchFlightById(db, params.id ?? '')
if (flight == null) {
return json({ message: 'Not found' }, { status: 404 })
return data({ message: 'Not found' }, { status: 404 })
}
return json(flight)
return data(flight)
} catch (error) {
Sentry.captureException(error)
return json({ message: 'Internal server error' }, { status: 500 })
return data({ message: 'Internal server error' }, { status: 500 })
}
}
8 changes: 4 additions & 4 deletions apps/web/app/routes/api.flights.all.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { makeDatabaseConnection } from '@mach/shared-database'
import {
type HeadersFunction,
type LoaderFunctionArgs,
json,
data,
} from '@remix-run/cloudflare'
import * as Sentry from '@sentry/remix'
import { fetchFlights, fetchFlightsSchema } from '../services/fetch-flights'
Expand All @@ -26,12 +26,12 @@ export async function loader({ request, context }: LoaderFunctionArgs) {
})

if (!query.success) {
return json({ message: 'Bad Request' }, { status: 400 })
return data({ message: 'Bad Request' }, { status: 400 })
}

return json(await fetchFlights(db, query.data))
return data(await fetchFlights(db, query.data))
} catch (error) {
Sentry.captureException(error)
return json({ message: 'Internal server error' }, { status: 500 })
return data({ message: 'Internal server error' }, { status: 500 })
}
}
8 changes: 4 additions & 4 deletions apps/web/app/routes/api.flights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { makeDatabaseConnection } from '@mach/shared-database'
import {
type HeadersFunction,
type LoaderFunctionArgs,
json,
data,
} from '@remix-run/cloudflare'
import * as Sentry from '@sentry/remix'
import {
Expand Down Expand Up @@ -33,13 +33,13 @@ export async function loader({ request, context }: LoaderFunctionArgs) {
)

if (!query.success || !paginate.success) {
return json({ message: 'Bad Request' }, { status: 400 })
return data({ message: 'Bad Request' }, { status: 400 })
}
const response = await fetchFlights(db, query.data, paginate.data)

return json(response)
return data(response)
} catch (error) {
Sentry.captureException(error)
return json({ message: 'Internal server error' }, { status: 500 })
return data({ message: 'Internal server error' }, { status: 500 })
}
}
4 changes: 2 additions & 2 deletions apps/web/app/routes/api.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LoaderFunctionArgs, json } from '@remix-run/cloudflare'
import { data } from '@remix-run/cloudflare'

const openApi = {
openapi: '3.0.1',
Expand Down Expand Up @@ -392,7 +392,7 @@ const openApi = {
}

export async function loader() {
return json(openApi, {
return data(openApi, {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
Expand Down
11 changes: 10 additions & 1 deletion apps/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ export default defineConfig({
},
plugins: [
remixCloudflareDevProxy(),
remix(),
remix({
future: {
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
v3_lazyRouteDiscovery: true,
v3_singleFetch: true,
v3_routeConfig: true,
},
}),
envOnlyMacros(),
nxViteTsPaths(),
sentryVitePlugin({
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@commitlint/config-conventional": "^19.6.0",
"@libsql/client": "^0.14.0",
"@mach/shared-eslint-config": "workspace:*",
"@mach/web": "workspace:^",
"@nx-aws-plugin/nx-aws-cache": "^3.2.3",
"@nx/devkit": "20.3.0",
"@nx/eslint": "20.3.0",
Expand All @@ -22,7 +23,9 @@
"@remix-run/cloudflare": "^2.15.2",
"@remix-run/cloudflare-pages": "^2.15.2",
"@remix-run/dev": "^2.15.2",
"@remix-run/fs-routes": "^2.15.2",
"@remix-run/react": "^2.15.2",
"@remix-run/route-config": "^2.15.2",
"@remix-run/serve": "^2.15.2",
"@semantic-release/exec": "^6.0.0",
"@semantic-release/git": "^10.0.1",
Expand Down
40 changes: 40 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1c2919d

Please sign in to comment.