feat: graphql client with fetches for initial pages

This commit is contained in:
Simon Emanuelsson
2024-02-01 16:19:16 +01:00
parent a91781137a
commit 5e974aa3da
56 changed files with 2580 additions and 1512 deletions
+33
View File
@@ -0,0 +1,33 @@
// @ts-check
/**
* This file is included in `/next.config.mjs` which ensures the app isn't built with invalid env vars.
* It has to be a `.mjs`-file to be imported there.
*/
import { serverSchema, serverEnv } from './schema.mjs'
import { env as clientEnv, formatErrors } from './client.mjs'
const _serverEnv = serverSchema.safeParse(serverEnv)
if (!_serverEnv.success) {
const msg = [
'❌ Invalid environment variables [Server]:\n',
...formatErrors(_serverEnv.error.format()),
].join('')
console.error(msg)
throw new Error(msg)
}
for (let key of Object.keys(_serverEnv.data)) {
const msg = []
if (key.startsWith('NEXT_PUBLIC_')) {
msg.push(
`❌ You are exposing a server-side env-variable: ${key}\n`
)
}
if (msg.length) {
console.warn(msg.join(''))
throw new Error(msg.join(''))
}
}
export const env = { ..._serverEnv.data, ...clientEnv }