diff --git a/apps/web/app/routes.ts b/apps/web/app/routes.ts new file mode 100644 index 00000000..1185cfe6 --- /dev/null +++ b/apps/web/app/routes.ts @@ -0,0 +1,3 @@ +import { flatRoutes } from '@remix-run/fs-routes' + +export default flatRoutes() diff --git a/apps/web/app/routes/api.flights.$id.tsx b/apps/web/app/routes/api.flights.$id.tsx index d9334dee..6167c845 100644 --- a/apps/web/app/routes/api.flights.$id.tsx +++ b/apps/web/app/routes/api.flights.$id.tsx @@ -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' @@ -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 }) } } diff --git a/apps/web/app/routes/api.flights.all.tsx b/apps/web/app/routes/api.flights.all.tsx index 7f45af73..09da3744 100644 --- a/apps/web/app/routes/api.flights.all.tsx +++ b/apps/web/app/routes/api.flights.all.tsx @@ -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' @@ -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 }) } } diff --git a/apps/web/app/routes/api.flights.tsx b/apps/web/app/routes/api.flights.tsx index d4ba4393..3cdb9a32 100644 --- a/apps/web/app/routes/api.flights.tsx +++ b/apps/web/app/routes/api.flights.tsx @@ -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 { @@ -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 }) } } diff --git a/apps/web/app/routes/api.tsx b/apps/web/app/routes/api.tsx index 3c181b69..4ee2f1a6 100644 --- a/apps/web/app/routes/api.tsx +++ b/apps/web/app/routes/api.tsx @@ -1,4 +1,4 @@ -import { LoaderFunctionArgs, json } from '@remix-run/cloudflare' +import { data } from '@remix-run/cloudflare' const openApi = { openapi: '3.0.1', @@ -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', diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index a8bbc82f..99a25538 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -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({ diff --git a/package.json b/package.json index 291e1d87..1074b2bf 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 71650716..870def43 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,9 @@ importers: '@mach/shared-eslint-config': specifier: workspace:* version: link:modules/shared-eslint-config + '@mach/web': + specifier: workspace:^ + version: link:apps/web '@nx-aws-plugin/nx-aws-cache': specifier: ^3.2.3 version: 3.2.3(@aws-sdk/client-sso-oidc@3.716.0)(@nx/devkit@20.3.0)(@nx/workspace@20.3.0)(nx@20.3.0) @@ -56,9 +59,15 @@ importers: '@remix-run/dev': specifier: ^2.15.2 version: 2.15.2(@remix-run/react@2.15.2)(@remix-run/serve@2.15.2)(@types/node@22.10.2)(less@4.1.3)(stylus@0.64.0)(typescript@5.7.2)(vite@5.4.11)(wrangler@3.99.0) + '@remix-run/fs-routes': + specifier: ^2.15.2 + version: 2.15.2(@remix-run/dev@2.15.2)(@remix-run/route-config@2.15.2)(typescript@5.7.2) '@remix-run/react': specifier: ^2.15.2 version: 2.15.2(react-dom@18.3.1)(react@18.3.1)(typescript@5.7.2) + '@remix-run/route-config': + specifier: ^2.15.2 + version: 2.15.2(@remix-run/dev@2.15.2)(typescript@5.7.2) '@remix-run/serve': specifier: ^2.15.2 version: 2.15.2(typescript@5.7.2) @@ -7989,6 +7998,22 @@ packages: typescript: 5.7.2 dev: true + /@remix-run/fs-routes@2.15.2(@remix-run/dev@2.15.2)(@remix-run/route-config@2.15.2)(typescript@5.7.2): + resolution: {integrity: sha512-Ozf0ab5OcyJ0OcOHtjO726VptDXMOp+xek6n/Wp3A+IcaY2tmWWChYsw8O0dKZ5Q5BCJv3hlLX99PLadX9wqeg==} + engines: {node: '>=18.0.0'} + peerDependencies: + '@remix-run/dev': ^2.15.2 + '@remix-run/route-config': ^2.15.2 + typescript: ^5.1.0 + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@remix-run/dev': 2.15.2(@remix-run/react@2.15.2)(@remix-run/serve@2.15.2)(@types/node@22.10.2)(less@4.1.3)(stylus@0.64.0)(typescript@5.7.2)(vite@5.4.11)(wrangler@3.99.0) + '@remix-run/route-config': 2.15.2(@remix-run/dev@2.15.2)(typescript@5.7.2) + typescript: 5.7.2 + dev: true + /@remix-run/node@2.15.2(typescript@5.7.2): resolution: {integrity: sha512-NS/h5uxje7DYCNgcKqKAiUhf0r2HVnoYUBWLyIIMmCUP1ddWurBP6xTPcWzGhEvV/EvguniYi1wJZ5+X8sonWw==} engines: {node: '>=18.0.0'} @@ -8029,6 +8054,21 @@ packages: typescript: 5.7.2 dev: true + /@remix-run/route-config@2.15.2(@remix-run/dev@2.15.2)(typescript@5.7.2): + resolution: {integrity: sha512-xAbH3VCgsvUK3YH2INU7yhZMjbw5bGoSaGEGS3k+QdX8a9gWeFKPex+w76ZNjVNVVOMOE+yJVpdN9RrIu0Pfeg==} + engines: {node: '>=18.0.0'} + peerDependencies: + '@remix-run/dev': ^2.15.2 + typescript: ^5.1.0 + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@remix-run/dev': 2.15.2(@remix-run/react@2.15.2)(@remix-run/serve@2.15.2)(@types/node@22.10.2)(less@4.1.3)(stylus@0.64.0)(typescript@5.7.2)(vite@5.4.11)(wrangler@3.99.0) + lodash: 4.17.21 + typescript: 5.7.2 + dev: true + /@remix-run/router@1.21.0: resolution: {integrity: sha512-xfSkCAchbdG5PnbrKqFWwia4Bi61nH+wm8wLEqfHDyp7Y3dZzgqS2itV8i4gAq9pC2HsTpwyBC6Ds8VHZ96JlA==} engines: {node: '>=14.0.0'}