-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Use env file instead of process.env everywhere
- Loading branch information
Showing
20 changed files
with
160 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { buildSchema } from "./schema"; | ||
|
||
export default buildSchema.parse({ | ||
DEPLOYMENT: process.env.DEPLOYMENT, | ||
CURRENT_PERIOD: process.env.CURRENT_PERIOD, | ||
FIRST_PERIOD: process.env.CURRENT_PERIOD, | ||
VERSION: process.env.VERSION, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const { z } = require("zod"); | ||
|
||
export const buildSchema = z.object({ | ||
// Used to display a mention of the current deployment in development mode | ||
DEPLOYMENT: z.string().optional(), | ||
CURRENT_PERIOD: z.string().default("2025"), | ||
FIRST_PERIOD: z.string().default("2009"), | ||
VERSION: z.string().optional(), | ||
}); | ||
|
||
// Define the schema for server-side variables | ||
export const serverSchema = z.object({ | ||
// Gever document download | ||
EIAM_CERTIFICATE_CONTENT: z.string().optional(), | ||
EIAM_CERTIFICATE_PASSWORD: z.string().optional(), | ||
EIAM_CERTIFICATE_PATH: z.string().optional(), | ||
GEVER_BINDING_IPSTS: z | ||
.string() | ||
.default( | ||
"https://idp-cert.gate-r.eiam.admin.ch/auth/sts/v14/certificatetransport" | ||
), | ||
GEVER_BINDING_RPSTS: z | ||
.string() | ||
.default( | ||
"https://feds-r.eiam.admin.ch/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256" | ||
), | ||
GEVER_BINDING_SERVICE: z | ||
.string() | ||
.default( | ||
"https://api-bv.egov-abn.uvek.admin.ch/BusinessManagement/GeverService/GeverServiceAdvanced.svc" | ||
), | ||
DEBUG_DOWNLOAD_SECRET: z | ||
.string() | ||
.default("GqQF$t$Fm^oddinivkY8TT8F^kRuRUJ$NJ5Jt%vQ"), | ||
|
||
ELCOM_ENV: z.string().optional(), | ||
|
||
// Gitlab as CMS | ||
GITLAB_WIKI_TOKEN: z.string().optional(), | ||
GITLAB_WIKI_URL: z.string().optional(), | ||
|
||
// Tracking | ||
MATOMO_ID: z.string().optional(), | ||
|
||
// Apollo plugin | ||
METRICS_PLUGIN_ENABLED: z.string().optional(), | ||
|
||
NODE_ENV: z.string(), | ||
|
||
// Sparql | ||
SPARQL_EDITOR: z.string().optional(), | ||
SPARQL_ENDPOINT: z.string().default("https://test.lindas.admin.ch/query"), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { serverSchema } from "./schema"; | ||
|
||
export default serverSchema.parse(process.env); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function assert(predicate: boolean, message: string): asserts predicate { | ||
if (!predicate) { | ||
throw new Error(message); | ||
} | ||
} | ||
|
||
export default assert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
import serverEnv from "src/env/server"; | ||
import assert from "src/lib/assert"; | ||
|
||
export default async (req: NextApiRequest, res: NextApiResponse) => { | ||
res.json({ matomoId: process.env.MATOMO_ID }); | ||
assert(!!serverEnv, "serverEnv is not defined"); | ||
res.json({ matomoId: serverEnv.MATOMO_ID }); | ||
}; |
Oops, something went wrong.