MCPcopy
hub / github.com/redwoodjs/graphql / resolveOptions

Function resolveOptions

packages/api-server/src/createServerHelpers.ts:83–161  ·  view source on GitHub ↗
(
  options: CreateServerOptions = {},
  args?: string[],
)

Source from the content-addressed store, hash-verified

81>
82
83export function resolveOptions(
84 options: CreateServerOptions = {},
85 args?: string[],
86) {
87 options.parseArgs ??= true
88
89 options.logger ??= DEFAULT_CREATE_SERVER_OPTIONS.logger
90
91 // Set defaults.
92 const resolvedOptions: ResolvedOptions = {
93 apiRootPath:
94 options.apiRootPath ?? DEFAULT_CREATE_SERVER_OPTIONS.apiRootPath,
95
96 fastifyServerOptions: options.fastifyServerOptions ?? {
97 requestTimeout:
98 DEFAULT_CREATE_SERVER_OPTIONS.fastifyServerOptions.requestTimeout,
99 logger: options.logger ?? DEFAULT_CREATE_SERVER_OPTIONS.logger,
100 bodyLimit: DEFAULT_CREATE_SERVER_OPTIONS.fastifyServerOptions.bodyLimit,
101 },
102 discoverFunctionsGlob:
103 options.discoverFunctionsGlob ??
104 DEFAULT_CREATE_SERVER_OPTIONS.discoverFunctionsGlob,
105 configureApiServer:
106 options.configureApiServer ??
107 DEFAULT_CREATE_SERVER_OPTIONS.configureApiServer,
108 apiHost: getAPIHost(),
109 apiPort: getAPIPort(),
110 }
111
112 // Merge fastifyServerOptions.
113 resolvedOptions.fastifyServerOptions.requestTimeout ??=
114 DEFAULT_CREATE_SERVER_OPTIONS.fastifyServerOptions.requestTimeout
115 resolvedOptions.fastifyServerOptions.logger = options.logger
116
117 if (options.parseArgs) {
118 const { values } = parseArgs({
119 options: {
120 apiHost: {
121 type: 'string',
122 },
123 apiPort: {
124 type: 'string',
125 short: 'p',
126 },
127 apiRootPath: {
128 type: 'string',
129 },
130 },
131 strict: false,
132 ...(args && { args }),
133 })
134
135 if (values.apiHost && typeof values.apiHost !== 'string') {
136 throw new Error('`apiHost` must be a string')
137 }
138 if (values.apiHost) {
139 resolvedOptions.apiHost = values.apiHost
140 }

Callers 2

createServerFunction · 0.90

Calls 4

getAPIHostFunction · 0.90
getAPIPortFunction · 0.90
coerceRootPathFunction · 0.90
parseArgsFunction · 0.50

Tested by

no test coverage detected