-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build time validation for client env
- Loading branch information
Showing
6 changed files
with
39 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,4 @@ | ||
{{={= =}=}} | ||
import * as z from 'zod' | ||
|
||
import { ensureEnvSchema } from '../env/index.js' | ||
|
||
const clientEnvSchema = z.object({ | ||
REACT_APP_API_URL: z | ||
.string({ | ||
required_error: 'REACT_APP_API_URL is required', | ||
}) | ||
.default('{= defaultServerUrl =}') | ||
}) | ||
import { clientEnvSchema } from './env/schema.js' | ||
|
||
export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) |
12 changes: 12 additions & 0 deletions
12
waspc/data/Generator/templates/sdk/wasp/client/env/schema.ts
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,12 @@ | ||
{{={= =}=}} | ||
import * as z from 'zod' | ||
|
||
// PRIVATE API (SDK, Vite config) | ||
export const clientEnvSchema = z.object({ | ||
REACT_APP_API_URL: z | ||
.string() | ||
.url({ | ||
message: 'REACT_APP_API_URL must be a valid URL', | ||
}) | ||
.default('{= defaultServerUrl =}'), | ||
}) |
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