(argv)
| 16 | import { exitWithError } from '../lib/exit' |
| 17 | |
| 18 | export 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 | ) |
no test coverage detected