Skip to content

Commit

Permalink
ADD: status page
Browse files Browse the repository at this point in the history
  • Loading branch information
fileformat committed Aug 8, 2024
1 parent 52d3409 commit 2da3725
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions app/routes/status[.]json.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { LoaderFunctionArgs } from "@remix-run/node";

export async function loader({
request,
}: LoaderFunctionArgs) {

const jsonStr = JSON.stringify({
success: true,
message: 'OK',
timestamp: new Date().toISOString(),
tech: `NodeJS ${process.version}`,
lastmod: process.env.LASTMOD || '(not set)',
commit: process.env.COMMIT || '(not set)',
});

const u = new URL(request.url);
const callback = u.searchParams.get('callback');
if (callback && /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(callback)) {
return new Response(`${callback}(${jsonStr});`, {
headers: {
"Content-Type": "text/javascript; charset=utf-8",
},
});
} else {
return new Response(jsonStr, {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, GET',
'Access-Control-Max-Age': '604800',
'Content-Type': 'application/json; charset=utf-8',
},
});
}
}

0 comments on commit 2da3725

Please # to comment.