Skip to content

Commit

Permalink
feat(xo-server): make http.listen config an object
Browse files Browse the repository at this point in the history
It remains compatible with previous configurations.

It now aligns with xo-proxy's config and is easier to overload with other config files.
  • Loading branch information
julien-f committed Aug 10, 2022
1 parent dbb9e4d commit 75a9799
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@

- @xen-orchestra/fs minor
- vhd-lib major
- xo-server minor

<!--packages-end-->
10 changes: 9 additions & 1 deletion packages/xo-server/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@ threshold = 1000
#[http.helmet.hsts]
#includeSubDomains = false

[[http.listen]]
# Each `http.listen.<name>` entry defines a specific listening configuration for
# the HTTP server.
#
# `<name>` can be freely choosen.
#
# Historically, `http.listen` was an array with the first config for HTTP and
# the second for HTTPS. To avoid breaking existing user configs, this convention
# is kept.
[http.listen.0]
port = 80

# These options are applied to all listen entries.
Expand Down
5 changes: 2 additions & 3 deletions packages/xo-server/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import has from 'lodash/has.js'
import helmet from 'helmet'
import httpProxy from 'http-proxy'
import includes from 'lodash/includes.js'
import map from 'lodash/map.js'
import memoryStoreFactory from 'memorystore'
import merge from 'lodash/merge.js'
import ms from 'ms'
Expand Down Expand Up @@ -474,8 +473,8 @@ async function makeWebServerListen(

async function createWebServer({ listen, listenOptions }) {
const webServer = stoppable(new WebServer())
await Promise.all(
map(listen, (opts, configKey) => makeWebServerListen(webServer, { ...listenOptions, ...opts, configKey }))
await asyncMap(Object.entries(listen), ([configKey, opts]) =>
makeWebServerListen(webServer, { ...listenOptions, ...opts, configKey })
)

return webServer
Expand Down

0 comments on commit 75a9799

Please sign in to comment.