-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): port defaults to
PORT
environment variable
- Loading branch information
1 parent
62b9b77
commit 4a079b8
Showing
2 changed files
with
9 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4a079b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change. Proposing to use
parseInt(process.env.PORT, 10) || 8080
4a079b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Xiphe check out https://github.com/xing/hops/blob/master/packages/express/lib/utils.js#L83-L86
When
hopsConfig.port
is defined, we will use that port and exit if it isn't free.When
hopsConfig.port
is not defined, we will default to 8080 and increase by one until we find a free port.So I'd argue that this isn't a breaking change, because the default behavior is basically the same:
When you do not define a port in your config it will use 8080 - previously it would exit if that port wasn't available, now it will just try to find the next free port.
4a079b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were using
import { port } from 'hops-config'
to configure our end-to-end tests in development. Previously this was8080
and now it'sundefined
. What you're describing means that you internally cared for the breaking change. Nevertheless this change requires a migration for consumers of the package.But I understand now that defaulting to
undefined
is cleaner than using the proposedparseInt(process.env.PORT, 10) || 8080
. Since it reflects the fact thathops-config
does not really know the port.