Skip to content

Commit

Permalink
Merge pull request #198 from curveball/prep-0.19
Browse files Browse the repository at this point in the history
Rename publicBaseUrl to origin and prep for release
  • Loading branch information
evert committed Apr 25, 2022
2 parents 3ddcdd1 + 964be84 commit e4005a1
Show file tree
Hide file tree
Showing 16 changed files with 287 additions and 185 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
}
],
"semi": ["error", "always"],
"no-console": ["error", { "allow": ["warn", "error", "info", "debug"] }],
"no-trailing-spaces": "error",
"eol-last": "error",
"@typescript-eslint/ban-ts-comment": ["error",
Expand All @@ -61,7 +62,6 @@
}],
"@typescript-eslint/prefer-for-of": ["error"],
"@typescript-eslint/prefer-optional-chain": ["error"],
"@typescript-eslint/prefer-ts-expect-error": ["error"],
"no-console": ["error"]
"@typescript-eslint/prefer-ts-expect-error": ["error"]
}
}
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -40,6 +40,6 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x
- run: npm ci
- run: npm run lint
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ It has the following methods
an internal HTTP request and return the result.
* `subRequest(request: Request)` - Run an internal HTTP request and return the
result.
* `origin` - Sets the 'origin' for the application. This is used to determine
absolute URIs. You can set the `origin` directly on the application, but
you can also set a `CURVEBALL_ORIGIN` environment variable. If nothing is
set this value will default to `http://localhost`.


### The Context class
Expand All @@ -283,6 +287,7 @@ The Context object has the following properties:
* `push(callback: Middleware)` - Do a HTTP/2 push.
* `redirect(status, location)` - Send a redirect status code and set a
`Location` header.
* `absoluteUrl` - The absolute URL for the request.


### The Request interface
Expand All @@ -307,6 +312,13 @@ properties and methods:
request matches the argument. If your `Content-Type` is
`application/hal+json` it will return true for `application/hal+json`,
`hal+json` and `json`.
* `origin` - The 'origin' for the request, for example:
`http://my-api:8008`.
* `absoluteUrl` - The absolute URL for the request.
* `ip()` - Returns the ip address of the client. This may be ipv4 or ipv6.
If `CURVEBALL_TRUSTPROXY` is set in the environment and truthy, this will
use the information from the `X-Forwarded-For` header (if available).



### The Response interface
Expand All @@ -328,6 +340,9 @@ properties and methods:
`hal+json` and `json`.
* `redirect(status, location)` - Send a redirect status code and set a
`Location` header.
* `origin` - The 'origin' for the request, for example:
`http://my-api:8008`.


### The Headers interface

Expand Down
19 changes: 19 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
Changelog
=========

0.19.0 (2022-04-25)
-------------------

* Now requires Node 14.
* `Application`, `Context`, `Request` and `Response` now have a `origin`
property. This defaults defaults to `http://localhost`. This can be
overridden by setting `Application.origin`, or setting a
`CURVEBALL_ORIGIN` environment variable. `PUBLIC_URI` also works, but
it's mainly a fallback for earlier examples and recommendations.
* `Request` and `Context` now have a `absoluteUrl` property. This is
calculated based on the request path and the `origin`.
* BC Break: Due to the new `origin` property, all `Request` and
`Response` classes now have an extra constructor argument. This means
if you ever manually constructed any of these, there's a small change
you'll need to make. Typescript should point all these problems!
* If `CURVEBALL_TRUSTPROXY` is set, `request.ip()` will trust proxies
by default, and return the ip of the real client instead of the proxy.


0.18.0 (2022-04-16)
-------------------

Expand Down

0 comments on commit e4005a1

Please sign in to comment.