Skip to content

Commit

Permalink
env validation moved inside function on github modlues api
Browse files Browse the repository at this point in the history
  • Loading branch information
SachinSogoduRaju committed Sep 29, 2023
1 parent 6794a6b commit 96edc92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions radlab-ui/webapp/src/pages/api/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { withAuth } from "@/utils/middleware"
import { AuthedNextApiHandler } from "@/utils/types"
import { NextApiResponse } from "next"

const GIT_TOKEN_SECRET_KEY_NAME = envOrFail(
"GIT_TOKEN_SECRET_KEY_NAME",
process.env.GIT_TOKEN_SECRET_KEY_NAME,
)
const getModuleDataFromGitHub = async (
req: AuthedNextApiHandler,
res: NextApiResponse,
) => {
const GIT_TOKEN_SECRET_KEY_NAME = envOrFail(
"GIT_TOKEN_SECRET_KEY_NAME",
process.env.GIT_TOKEN_SECRET_KEY_NAME,
)

const { path } = req.body
const secret = await getSecretKeyValue(GIT_TOKEN_SECRET_KEY_NAME)
try {
Expand Down
8 changes: 4 additions & 4 deletions radlab-ui/webapp/src/pages/api/github/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { withAuth } from "@/utils/middleware"
import { AuthedNextApiHandler } from "@/utils/types"
import { NextApiResponse } from "next"

const GIT_TOKEN_SECRET_KEY_NAME = envOrFail(
"GIT_TOKEN_SECRET_KEY_NAME",
process.env.GIT_TOKEN_SECRET_KEY_NAME,
)
const getModulesFromGitHub = async (
_req: AuthedNextApiHandler,
res: NextApiResponse,
) => {
const GIT_TOKEN_SECRET_KEY_NAME = envOrFail(
"GIT_TOKEN_SECRET_KEY_NAME",
process.env.GIT_TOKEN_SECRET_KEY_NAME,
)
const secret = await getSecretKeyValue(GIT_TOKEN_SECRET_KEY_NAME)
const modules = await getGitHubModules(secret)
return res.status(200).json(modules)
Expand Down

0 comments on commit 96edc92

Please sign in to comment.