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

Function builder

packages/cli/src/commands/serve.js:21–174  ·  view source on GitHub ↗
(yargs)

Source from the content-addressed store, hash-verified

19 'Start a server for serving both the api and web sides'
20
21export const builder = async (yargs) => {
22 const rscEnabled = getConfig().experimental?.rsc?.enabled
23 const streamingEnabled = getConfig().experimental?.streamingSsr?.enabled
24
25 yargs
26 .command({
27 command: '$0',
28 description: bothServerCLIConfig.description,
29 builder: bothServerCLIConfig.builder,
30 handler: async (argv) => {
31 recordTelemetryAttributes({
32 command: 'serve',
33 port: argv.port,
34 host: argv.host,
35 socket: argv.socket,
36 })
37
38 // Run the server file, if it exists, with web side also
39 if (serverFileExists()) {
40 const { bothServerFileHandler } = await import(
41 './serveBothHandler.js'
42 )
43 await bothServerFileHandler(argv)
44 } else if (rscEnabled || streamingEnabled) {
45 const { bothSsrRscServerHandler } = await import(
46 './serveBothHandler.js'
47 )
48 await bothSsrRscServerHandler(argv, rscEnabled)
49 } else {
50 await bothServerCLIConfig.handler(argv)
51 }
52 },
53 })
54 .command({
55 command: 'api',
56 description: apiServerCLIConfig.description,
57 builder: apiServerCLIConfig.builder,
58 handler: async (argv) => {
59 recordTelemetryAttributes({
60 command: 'serve',
61 port: argv.port,
62 host: argv.host,
63 socket: argv.socket,
64 apiRootPath: argv.apiRootPath,
65 })
66
67 // Run the server file, if it exists, api side only
68 if (serverFileExists()) {
69 const { apiServerFileHandler } = await import('./serveApiHandler.js')
70 await apiServerFileHandler(argv)
71 } else {
72 await apiServerCLIConfig.handler(argv)
73 }
74 },
75 })
76 .command({
77 command: 'web',
78 description: webServerCLIConfig.description,

Callers

nothing calls this directly

Calls 11

getConfigFunction · 0.90
serverFileExistsFunction · 0.90
webSsrServerHandlerFunction · 0.90
getPathsFunction · 0.90
bothServerFileHandlerFunction · 0.85
bothSsrRscServerHandlerFunction · 0.85
apiServerFileHandlerFunction · 0.85
commandMethod · 0.80
existsSyncMethod · 0.65
errorMethod · 0.45

Tested by

no test coverage detected