File size: 1,054 Bytes
a296341
 
 
 
 
 
 
 
1c1e6e9
 
a296341
 
 
 
 
 
 
3b81d2d
 
a296341
3b81d2d
a296341
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use server"

import { getValidBoolean } from "@/lib/getValidBoolean"
import { getValidNumber } from "@/lib/getValidNumber"
import { getValidString } from "@/lib/getValidString"
import { DynamicConfig } from "@/types"

export async function getDynamicConfig(): Promise<DynamicConfig> {
  const maxNbPages = getValidNumber(process.env.MAX_NB_PAGES, 1, Number.MAX_SAFE_INTEGER, 1)
  const nbPanelsPerPage = 4 // for now this is static
  const nbTotalPanelsToGenerate = maxNbPages * nbPanelsPerPage

  const config = {
    maxNbPages,
    nbPanelsPerPage,
    nbTotalPanelsToGenerate,
    oauthClientId: getValidString(process.env.HUGGING_FACE_OAUTH_CLIENT_ID, ""),

    // this doesn't work (conceptually)
    oauthRedirectUrl: getValidString(process.env.HUGGING_FACE_OAUTH_REDIRECT_URL, ""),

    oauthScopes: "openid profile inference-api",
    enableHuggingFaceOAuth: getValidBoolean(process.env.ENABLE_HUGGING_FACE_OAUTH, false),
    enableHuggingFaceOAuthWall: getValidBoolean(process.env.ENABLE_HUGGING_FACE_OAUTH_WALL, false),
  }

  return config
}