Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server file): add createServer #9845

Merged
merged 34 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
858cdaa
update server file to more finalized api
jtoar Oct 26, 2023
3610b75
createServer: Type `start`
Tobbe Jan 18, 2024
7329e51
make start options optional
jtoar Jan 18, 2024
1755f9f
Use Object.assign instead of spread to avoid copying object
Tobbe Jan 18, 2024
db5790f
move setup server file out of exp
jtoar Jan 18, 2024
c795c4f
remove experimental warning from dev server
jtoar Jan 18, 2024
be8178b
temporary fix for graphql
jtoar Jan 19, 2024
abf8b2a
add babel plugin
jtoar Jan 19, 2024
93d7d94
babel graphql extract plugin
Josh-Walker-GM Jan 19, 2024
a4f7f6c
revert graphql function
Josh-Walker-GM Jan 19, 2024
501b3ea
wip
Josh-Walker-GM Jan 19, 2024
56f36bc
handle apiRootPath in graphql
jtoar Jan 19, 2024
b6081bc
add filterFn to loadFunctions
jtoar Jan 19, 2024
ed74c95
fix filter fn options
jtoar Jan 19, 2024
6cf9a57
rename rw fastify plugin
jtoar Jan 19, 2024
4e59299
fix babel plugin
Josh-Walker-GM Jan 19, 2024
7c9fd71
remove unused graphql plugin from fastify package
jtoar Jan 19, 2024
97f0671
rm space from dirname lol
jtoar Jan 19, 2024
b36edeb
conditionally register graphql plugin
jtoar Jan 19, 2024
22b45e0
copy over dotenv-defaults fix
jtoar Jan 19, 2024
92a08da
get tests passing
jtoar Jan 19, 2024
8a283b5
refactor some tests
jtoar Jan 19, 2024
4168c36
move context up
jtoar Jan 19, 2024
8ccadeb
remove context from graphql
jtoar Jan 19, 2024
77f7262
pass cli args through to watch
jtoar Jan 19, 2024
fbde827
improve comments
jtoar Jan 19, 2024
cde8091
comment graphql options
jtoar Jan 20, 2024
9bdb885
improve mocks in tests
jtoar Jan 20, 2024
458a3f1
remove console log from serve api
jtoar Jan 20, 2024
8394041
style
jtoar Jan 20, 2024
4f20d4b
work on options
jtoar Jan 20, 2024
5898eae
work on entry points
jtoar Jan 20, 2024
f417191
use concurrently in serve
jtoar Jan 21, 2024
b979239
fix typo in error
jtoar Jan 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use concurrently in serve
  • Loading branch information
jtoar committed Jan 21, 2024
commit f417191b2b556866b829aa812c82c9a495cd3dc2
50 changes: 36 additions & 14 deletions packages/cli/src/commands/serveBothHandler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path'

import chalk from 'chalk'
import concurrently from 'concurrently'
import execa from 'execa'

import {
Expand All @@ -10,6 +11,9 @@
redwoodFastifyWeb,
} from '@redwoodjs/fastify'
import { getConfig, getPaths } from '@redwoodjs/project-config'
import { errorTelemetry } from '@redwoodjs/telemetry'

import { exitWithError } from '../lib/exit'

export const bothServerFileHandler = async (argv) => {
if (
Expand All @@ -24,25 +28,43 @@
shell: true,
})
} else {
execa(
'yarn',
['node', path.join('dist', 'server.js'), '--port', argv.apiPort],
const apiHost = `http://0.0.0.0:${argv.apiPort}`

const { result } = concurrently(
[
{
name: 'api',
command: `yarn node ${path.join('dist', 'server.js')} --port ${
argv.apiPort
}`,
cwd: getPaths().api.base,
prefixColor: 'cyan',
},
{
name: 'web',
command: `yarn rw-web-server --port ${argv.webPort} --api-host ${apiHost}`,
cwd: getPaths().base,
prefixColor: 'blue',
},
],
{
cwd: getPaths().api.base,
stdio: 'inherit',
prefix: '{name} |',
timestampFormat: 'HH:mm:ss',
handleInput: true,
}
)

const apiHost = `http://127.0.0.1:${argv.apiPort}`

execa(
'yarn',
['rw-web-server', '--port', argv.webPort, '--api-host', apiHost],
{
cwd: getPaths().base,
stdio: 'inherit',
try {
await result
} catch (error) {
if (typeof e?.message !== 'undefined') {

Check failure on line 60 in packages/cli/src/commands/serveBothHandler.js

View workflow job for this annotation

GitHub Actions / 🏗 Build, lint, test / ubuntu-latest / node 20 latest

'e' is not defined
errorTelemetry(
process.argv,
`Error concurrently starting sides: ${e.message}`

Check failure on line 63 in packages/cli/src/commands/serveBothHandler.js

View workflow job for this annotation

GitHub Actions / 🏗 Build, lint, test / ubuntu-latest / node 20 latest

'e' is not defined
)
exitWithError(e)

Check failure on line 65 in packages/cli/src/commands/serveBothHandler.js

View workflow job for this annotation

GitHub Actions / 🏗 Build, lint, test / ubuntu-latest / node 20 latest

'e' is not defined
}
)
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/web-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ async function serve() {
if (options.socket) {
console.log(`Web server started on ${options.socket}`)
} else {
console.log(`Web server started on http://localhost:${options.port}`)
console.log(
`Web server started on http://${listenOptions.host}:${options.port}`
)
}
})

Expand Down
Loading