Skip to content

Commit b60012c

Browse files
committed
refactor: update route handling and improve observability
- Changed the condition for Sentry integration in reportRouteNotFound to check for SSR using import.meta.env.SSR. - Refactored the health route to utilize createFileRoute for better structure and response handling. - Updated BillingSuccessRedirect imports to reflect new feature organization, removing the old shared route file.
1 parent 4fe9bd9 commit b60012c

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed
File renamed without changes.

src/lib/observability/report-not-found.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function reportRouteNotFound(meta: NotFoundMetadata) {
1212
href: meta.href ?? null,
1313
};
1414

15-
if (typeof window === 'undefined') {
15+
if (import.meta.env.SSR) {
1616
const { Sentry } = await import('./sentry.server');
1717
if (Sentry?.captureMessage) {
1818
Sentry.captureMessage('Router 404', (scope) => {

src/routes/billing/success/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createFileRoute } from '@tanstack/react-router';
22

3-
import { BillingSuccessRedirect } from '~/routes/shared/BillingSuccessRedirect';
3+
import { BillingSuccessRedirect } from '~/features/billing/BillingSuccessRedirect';
44

55
export const Route = createFileRoute('/billing/success')({
66
component: BillingSuccessRedirect,

src/routes/dashboard/billing/success/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createFileRoute } from '@tanstack/react-router';
22

3-
import { BillingSuccessRedirect } from '~/routes/shared/BillingSuccessRedirect';
3+
import { BillingSuccessRedirect } from '~/features/billing/BillingSuccessRedirect';
44

55
export const Route = createFileRoute('/dashboard/billing/success')({
66
component: BillingSuccessRedirect,

src/routes/health.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
/**
2-
* Minimal healthcheck endpoint for Dokku.
3-
* Responds with 200 and a small JSON body.
4-
*/
5-
export async function GET() {
6-
return new Response(JSON.stringify({ status: 'ok' }), {
7-
headers: { 'content-type': 'application/json; charset=utf-8' },
8-
status: 200,
9-
});
10-
}
1+
import { createFileRoute } from '@tanstack/react-router';
112

12-
// Optional: treat HEAD like GET (fast path for some checkers)
13-
export const HEAD = GET;
3+
const jsonOk = () =>
4+
Response.json(
5+
{ status: 'ok' },
6+
{
7+
headers: { 'content-type': 'application/json; charset=utf-8' },
8+
status: 200,
9+
},
10+
);
11+
12+
export const Route = createFileRoute('/health')({
13+
component: () => null,
14+
server: {
15+
handlers: {
16+
GET: jsonOk,
17+
HEAD: () => new Response(null, { status: 200 }),
18+
},
19+
},
20+
});

0 commit comments

Comments
 (0)