Skip to content

Commit

Permalink
feat(status): apply fetch action to check the status of the server (#171
Browse files Browse the repository at this point in the history
)
  • Loading branch information
SWARVY committed Jun 25, 2024
1 parent 1a72558 commit 594fa37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
12 changes: 3 additions & 9 deletions apps/status/src/shared/constant/serviceList.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
export const SERVICE_LIST = {
Auth: 'https://auth.clab.page/',
Member: 'https://www.clab.page/',
Land: 'https:///play.clab.page/',
};

export const SERVICE_STATUS_LIST = {
Auth: true,
Member: false,
Land: true,
Auth: 'https://api.clab.page/',
Member: 'https://api.clab.page/',
Land: 'https:///api.clab.page/',
};
20 changes: 12 additions & 8 deletions apps/status/src/widgets/service-status/ui/CurrentServices.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { SERVICE_LIST, SERVICE_STATUS_LIST, ServiceList } from '@/src/shared';
import { SERVICE_LIST } from '@/src/shared';
import Title from '@/src/shared/ui/Title';

import ServiceStatusItem from './ServiceStatusItem';

interface CurrentStatusProps {
status: boolean;
}

function StatusBanner({ status }: { status: boolean }) {
return (
<div
className={`w-full rounded-md ${status ? 'bg-green-600' : 'bg-red-500'} px-8 py-4 text-lg text-white`}
className={`w-full rounded-md ${status ? 'bg-green-500' : 'bg-red-500'} px-8 py-4 text-lg font-semibold text-white`}
>
{status
? '현재 서비스가 정상적으로 운영되고 있습니다.'
Expand All @@ -19,7 +15,15 @@ function StatusBanner({ status }: { status: boolean }) {
);
}

export default function CurrentStatus({ status }: CurrentStatusProps) {
export default async function CurrentStatus() {
const status = await fetch(
process.env.NODE_ENV !== 'production'
? process.env.DEVELOP_SERVER_URL ?? ''
: process.env.PRODUCTION_SERVER_URL ?? '',
)
.then((res) => res.status === 404)
.catch(() => false);

return (
<div className="flex w-full flex-col gap-y-10">
<StatusBanner status={status} />
Expand All @@ -34,7 +38,7 @@ export default function CurrentStatus({ status }: CurrentStatusProps) {
<ServiceStatusItem
serviceName={serviceName}
serviceURL={serviceURL}
status={SERVICE_STATUS_LIST[serviceName as ServiceList]}
status={status}
/>
))}
</ul>
Expand Down

0 comments on commit 594fa37

Please sign in to comment.