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

Function bothServerFileHandler

packages/cli/src/commands/serveBothHandler.js:18–80  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

16import { exitWithError } from '../lib/exit'
17
18export const bothServerFileHandler = async (argv) => {
19 if (
20 getConfig().experimental?.rsc?.enabled ||
21 getConfig().experimental?.streamingSsr?.enabled
22 ) {
23 logSkippingFastifyWebServer()
24
25 await execa('yarn', ['rw-serve-fe'], {
26 cwd: getPaths().web.base,
27 stdio: 'inherit',
28 shell: true,
29 })
30 } else {
31 argv.apiPort ??= getAPIPort()
32 argv.apiHost ??= getAPIHost()
33 argv.webPort ??= getWebPort()
34 argv.webHost ??= getWebHost()
35
36 const apiProxyTarget = [
37 'http://',
38 argv.apiHost.includes(':') ? `[${argv.apiHost}]` : argv.apiHost,
39 ':',
40 argv.apiPort,
41 argv.apiRootPath,
42 ].join('')
43
44 const { result } = concurrently(
45 [
46 {
47 name: 'api',
48 command: `yarn node ${path.join('dist', 'server.js')} --apiPort ${
49 argv.apiPort
50 } --apiHost ${argv.apiHost} --apiRootPath ${argv.apiRootPath}`,
51 cwd: getPaths().api.base,
52 prefixColor: 'cyan',
53 },
54 {
55 name: 'web',
56 command: `yarn rw-web-server --port ${argv.webPort} --host ${argv.webHost} --api-proxy-target ${apiProxyTarget}`,
57 cwd: getPaths().base,
58 prefixColor: 'blue',
59 },
60 ],
61 {
62 prefix: '{name} |',
63 timestampFormat: 'HH:mm:ss',
64 handleInput: true,
65 },
66 )
67
68 try {
69 await result
70 } catch (error) {
71 if (typeof error?.message !== 'undefined') {
72 errorTelemetry(
73 process.argv,
74 `Error concurrently starting sides: ${error.message}`,
75 )

Callers 1

builderFunction · 0.85

Calls 9

getConfigFunction · 0.90
getPathsFunction · 0.90
getAPIPortFunction · 0.90
getAPIHostFunction · 0.90
getWebPortFunction · 0.90
getWebHostFunction · 0.90
errorTelemetryFunction · 0.90
exitWithErrorFunction · 0.90

Tested by

no test coverage detected