From 590261a48f4fc94d0f3bff4bd52325c82888bb02 Mon Sep 17 00:00:00 2001 From: Shreyas Kallingal Date: Thu, 4 Apr 2024 02:34:38 -0700 Subject: [PATCH] Refactor course id into env variable and enforce min node version in package-json --- .env.example | 3 +++ package-lock.json | 3 +++ package.json | 1 + src/components/layout/Landing.tsx | 3 +-- src/components/layout/Navbar.tsx | 4 ++-- src/utils/constants.ts | 2 -- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index a2b20e9..82d0b41 100644 --- a/.env.example +++ b/.env.example @@ -14,3 +14,6 @@ NEXTAUTH_URL='http://localhost:3000' # Ably ABLY_SERVER_API_KEY='' NEXT_PUBLIC_ABLY_CLIENT_API_KEY='' + +# Course Info +COURSE_ID='' \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 28b806e..46d37d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,6 +52,9 @@ "prisma": "^5.0.0", "ts-node": "^10.9.1", "typescript": "^4.7.4" + }, + "engines": { + "node": ">18" } }, "node_modules/@ably-labs/react-hooks": { diff --git a/package.json b/package.json index f9a7394..3fd2a6a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "simple-office-hours-queue", + "engines" : { "node" : ">18.17" }, "version": "0.1.0", "private": true, "prisma": { diff --git a/src/components/layout/Landing.tsx b/src/components/layout/Landing.tsx index 815d340..abb6e00 100644 --- a/src/components/layout/Landing.tsx +++ b/src/components/layout/Landing.tsx @@ -1,5 +1,4 @@ import { Flex, Heading, Text } from "@chakra-ui/react"; -import { COURSE_ID } from "../../utils/constants"; /** * Sign in page UI. @@ -8,7 +7,7 @@ const Landing = () => { return ( - Welcome to the {COURSE_ID} Office Hours Queue + Welcome to the {process.env.COURSE_ID} Office Hours Queue Please sign in with your school email above to join or manage the queue. diff --git a/src/components/layout/Navbar.tsx b/src/components/layout/Navbar.tsx index c853373..5cd74ea 100644 --- a/src/components/layout/Navbar.tsx +++ b/src/components/layout/Navbar.tsx @@ -14,7 +14,7 @@ import { UserRole } from "@prisma/client"; import { useSession } from "next-auth/react"; import Link from "next/link"; import Router from "next/router"; -import { COURSE_ID, DARK_MODE_COLOR } from "../../utils/constants"; +import { DARK_MODE_COLOR } from "../../utils/constants"; import { trpc } from "../../utils/trpc"; import AvatarDropdown from "./AvatarDropdown"; import { DarkModeToggle } from "./DarkModeToggle"; @@ -76,7 +76,7 @@ export const Navbar = () => { fontWeight="semibold" fontSize="xl" > - {COURSE_ID} OH + {process.env.COURSE_ID} OH diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 88d870c..3908df4 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -1,5 +1,3 @@ -export const COURSE_ID = "CS61B"; - export const EMAIL_REGEX = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;