-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dynamic config resolver schemas and types
- Loading branch information
1 parent
74fba0c
commit 546fc8a
Showing
10 changed files
with
349 additions
and
86 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { z } from 'zod'; | ||
|
||
import { type ResolverSchemas } from '../../../../utils/config/config.types'; | ||
|
||
// Example usage: | ||
const resolverSchemas: ResolverSchemas = { | ||
COMPUTED: { | ||
args: z.undefined(), | ||
returnType: z.tuple([z.string()]), | ||
}, | ||
COMPUTED_WITH_ARG: { | ||
args: z.tuple([z.string()]), | ||
returnType: z.tuple([z.string()]), | ||
}, | ||
DYNAMIC: { | ||
args: z.undefined(), | ||
returnType: z.number(), | ||
}, | ||
DYNAMIC_WITH_ARG: { | ||
args: z.number(), | ||
returnType: z.number(), | ||
}, | ||
}; | ||
|
||
export default resolverSchemas; |
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,10 +1,21 @@ | ||
import getTransformedConfigs from './utils/config/get-transformed-configs'; | ||
import { setLoadedGlobalConfigs } from './utils/config/global-configs-ref'; | ||
import { registerLoggers } from './utils/logger'; | ||
import logger, { registerLoggers } from './utils/logger'; | ||
|
||
export async function register() { | ||
registerLoggers(); | ||
if (process.env.NEXT_RUNTIME === 'nodejs') { | ||
setLoadedGlobalConfigs(getTransformedConfigs()); | ||
try { | ||
const configs = await getTransformedConfigs(); | ||
setLoadedGlobalConfigs(configs); | ||
} catch (e) { | ||
// manually catching and logging the error to prevent the error being replaced | ||
// by "Cannot set property message of [object Object] which has only a getter" | ||
logger.error({ | ||
message: 'Failed to load configs', | ||
cause: String(e), | ||
}); | ||
process.exit(1); // use process.exit to exit without an extra error log from instrumentation | ||
} | ||
} | ||
} |
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
Oops, something went wrong.