Skip to content

Commit e4005a1

Browse files
authored
Merge pull request #198 from curveball/prep-0.19
Rename publicBaseUrl to origin and prep for release
2 parents 3ddcdd1 + 964be84 commit e4005a1

16 files changed

+287
-185
lines changed

.eslintrc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
}
3737
],
3838
"semi": ["error", "always"],
39+
"no-console": ["error", { "allow": ["warn", "error", "info", "debug"] }],
3940
"no-trailing-spaces": "error",
4041
"eol-last": "error",
4142
"@typescript-eslint/ban-ts-comment": ["error",
@@ -61,7 +62,6 @@
6162
}],
6263
"@typescript-eslint/prefer-for-of": ["error"],
6364
"@typescript-eslint/prefer-optional-chain": ["error"],
64-
"@typescript-eslint/prefer-ts-expect-error": ["error"],
65-
"no-console": ["error"]
65+
"@typescript-eslint/prefer-ts-expect-error": ["error"]
6666
}
6767
}

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

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

2323
steps:
@@ -40,6 +40,6 @@ jobs:
4040
- name: Use Node.js
4141
uses: actions/setup-node@v1
4242
with:
43-
node-version: 16.x
43+
node-version: 18.x
4444
- run: npm ci
4545
- run: npm run lint

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ It has the following methods
261261
an internal HTTP request and return the result.
262262
* `subRequest(request: Request)` - Run an internal HTTP request and return the
263263
result.
264+
* `origin` - Sets the 'origin' for the application. This is used to determine
265+
absolute URIs. You can set the `origin` directly on the application, but
266+
you can also set a `CURVEBALL_ORIGIN` environment variable. If nothing is
267+
set this value will default to `http://localhost`.
264268

265269

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

287292

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

311323

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

332347
### The Headers interface
333348

changelog.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
Changelog
22
=========
33

4+
0.19.0 (2022-04-25)
5+
-------------------
6+
7+
* Now requires Node 14.
8+
* `Application`, `Context`, `Request` and `Response` now have a `origin`
9+
property. This defaults defaults to `http://localhost`. This can be
10+
overridden by setting `Application.origin`, or setting a
11+
`CURVEBALL_ORIGIN` environment variable. `PUBLIC_URI` also works, but
12+
it's mainly a fallback for earlier examples and recommendations.
13+
* `Request` and `Context` now have a `absoluteUrl` property. This is
14+
calculated based on the request path and the `origin`.
15+
* BC Break: Due to the new `origin` property, all `Request` and
16+
`Response` classes now have an extra constructor argument. This means
17+
if you ever manually constructed any of these, there's a small change
18+
you'll need to make. Typescript should point all these problems!
19+
* If `CURVEBALL_TRUSTPROXY` is set, `request.ip()` will trust proxies
20+
by default, and return the ip of the real client instead of the proxy.
21+
22+
423
0.18.0 (2022-04-16)
524
-------------------
625

0 commit comments

Comments
 (0)