Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin committed Jan 1, 2024
1 parent 8ede937 commit 437057f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
20 changes: 20 additions & 0 deletions src/app/status/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { headers } from 'next/headers';

import { getStatus } from '../../api/status';
import { getRequestContext } from '../../utils/requestContext';
import Renderer from './renderer';

export default async function Page() {
const { props } = await get();
return <Renderer {...props} />
}

export async function get() {
const response: Response = await getStatus(getRequestContext(headers()));

return {
props: {
statusCode: response.status
}
}
}
17 changes: 2 additions & 15 deletions src/app/status/index.tsx → src/app/status/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import HeadMetaComponent from '../../components/headmeta';
import PlanePage from '../../components/planePage';
import { getStatus } from '../../api/status';
import { getRequestContext } from '../../utils/requestContext';
import { defaultRobotsMeta } from '../../../config';

const Page: React.FunctionComponent<{ statusCode: number }> = ({ statusCode }) => {
const Renderer: React.FunctionComponent<{ statusCode: number }> = ({ statusCode }) => {
// TODO: improvement (add bc-color, style, statusCode, etc)
return(
<>
Expand Down Expand Up @@ -34,15 +32,4 @@ const Page: React.FunctionComponent<{ statusCode: number }> = ({ statusCode }) =
);
}

export async function getServerSideProps(ctx: any) {
const response: Response = await getStatus(getRequestContext(ctx.req))
ctx.res.statusCode = response.status;

return {
props: {
statusCode: response.status
}
}
}

export default Page;
export default Renderer;

0 comments on commit 437057f

Please sign in to comment.