Skip to content

Commit 2c2b212

Browse files
committed
Refactor environment variable access to use process.env for consistency across the application
1 parent c6e3d4a commit 2c2b212

File tree

6 files changed

+9
-16
lines changed

6 files changed

+9
-16
lines changed

app/api/slurm/reservations/route.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
export const dynamic = 'force-dynamic';
22

33
import { NextResponse } from "next/server";
4-
import { env } from "process";
54
import { fetchSlurmData } from "@/lib/slurm-api";
65

76
export async function GET() {
87
const isEnabled =
9-
String(env.MAINT_NOTIFICATIONS_ENABLED ?? "true").toLowerCase() === "true";
8+
String(process.env.MAINT_NOTIFICATIONS_ENABLED ?? "true").toLowerCase() === "true";
109

1110
if (!isEnabled) {
1211
return NextResponse.json({ meta: { enabled: false }, reservations: [] });

app/layout.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import type { Metadata } from "next";
22
import { Inter } from "next/font/google";
33
import "./globals.css";
44
import { ThemeProvider } from "@/components/theme-provider";
5-
import { env } from "process";
65

76
const inter = Inter({ subsets: ["latin"] });
87

98
export const metadata: Metadata = {
10-
title: `${env.CLUSTER_NAME} Supercomputer`,
9+
title: `${process.env.CLUSTER_NAME} Supercomputer`,
1110
description: "A Slurm supercomputer dashboard.",
1211
icons: {
1312
icon: "/favicon.ico",

app/modules/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Footer from "@/components/footer/footer";
2-
import { env } from "process";
32

43
import Modules from "@/components/modules/modules";
54

@@ -8,7 +7,7 @@ export default function Dashboard() {
87
<div className="mb-5">
98
<div className="p-2 ml-2 mx-auto">
109
<Modules />
11-
<Footer cluster={env.CLUSTER_NAME} logo={env.CLUSTER_LOGO} />
10+
<Footer cluster={process.env.CLUSTER_NAME} logo={process.env.CLUSTER_LOGO} />
1211
</div>
1312
</div>
1413
);

app/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Footer from "@/components/footer/footer";
2-
import { env } from "process";
32

43
import Nodes from "@/components/nodeCard/nodes";
54

@@ -8,7 +7,7 @@ export default function Dashboard() {
87
<div className="mb-5">
98
<div className="p-2 ml-2 mx-auto">
109
<Nodes />
11-
<Footer cluster={env.CLUSTER_NAME} logo={env.CLUSTER_LOGO} />
10+
<Footer cluster={process.env.CLUSTER_NAME} logo={process.env.CLUSTER_LOGO} />
1211
</div>
1312
</div>
1413
);

app/rewind/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import Footer from "@/components/footer/footer";
22
import Rewind from "@/components/rewind/rewind";
3-
import { env } from "process";
43

54
export default function Dashboard() {
65
return (
76
<div className="mb-5">
87
<div className="p-2 ml-2 mx-auto">
98
<Rewind />
10-
<Footer cluster={env.CLUSTER_NAME} logo={env.CLUSTER_LOGO} />
9+
<Footer cluster={process.env.CLUSTER_NAME} logo={process.env.CLUSTER_LOGO} />
1110
</div>
1211
</div>
1312
);

lib/slurm-api.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { env } from "process";
2-
31
type SlurmApiType = 'slurm' | 'slurmdb';
42

53
interface FetchSlurmOptions {
@@ -17,14 +15,14 @@ export async function fetchSlurmData(endpoint: string, options: FetchSlurmOption
1715

1816
const { type = 'slurm', revalidate = 30, method = 'GET', body } = finalOptions;
1917

20-
const protocol = env.SLURM_PROTOCOL || 'http';
21-
const baseUrl = `${protocol}://${env.SLURM_SERVER}:6820/${type}/${env.SLURM_API_VERSION}`;
18+
const protocol = process.env.SLURM_PROTOCOL || 'http';
19+
const baseUrl = `${protocol}://${process.env.SLURM_SERVER}:6820/${type}/${process.env.SLURM_API_VERSION}`;
2220

2321
const fetchOptions: RequestInit = {
2422
method,
2523
headers: {
26-
"X-SLURM-USER-NAME": `${env.SLURM_API_ACCOUNT}`,
27-
"X-SLURM-USER-TOKEN": `${env.SLURM_API_TOKEN}`,
24+
"X-SLURM-USER-NAME": `${process.env.SLURM_API_ACCOUNT}`,
25+
"X-SLURM-USER-TOKEN": `${process.env.SLURM_API_TOKEN}`,
2826
...(body ? { "Content-Type": "application/json" } : {}),
2927
},
3028
next: {

0 commit comments

Comments
 (0)