Skip to content

Commit 8c8180b

Browse files
committed
Merge branch 'v2'
2 parents 21aa04a + a92bc32 commit 8c8180b

32 files changed

+956
-7633
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [unreleased]
9+
- Major update improving simplicity
10+
- Simplified build, now exported as ESM modules only.
11+
- Separated out Node.js support into its own export, `"@fanoutio/serve-grip/node"`.
12+
- This exports a version of `ServeGrip` that works with Node.js's `IncomingMessage` objects.
13+
- Added conditional export "node" that makes this available on the main `@fanoutio/serve-grip`
14+
export as well when the condition `"node"` is present when resolving imports.
15+
- Removed `IGripApiRequest` and `IGripApiResponse` interfaces.
16+
- Subclasses of `ServeGripBase` are now to work directly with the TRequest and TResponse objects.
917

1018
## [1.3.1] - 2023-09-14
1119
- Bump dependency versions

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ This library also supports legacy services hosted by [Fanout](https://fanout.io/
1818

1919
Authors: Katsuyuki Omuro <[email protected]>, Konstantin Bokarius <[email protected]>
2020

21+
## New for v2
22+
23+
### Breaking changes
24+
25+
- Simplified build, now exported as ESM modules only. If you require CommonJS support or
26+
a browser build, use v1.
27+
- A number of classes and interfaces have been removed for simplification.
28+
2129
### Introduction
2230

2331
[GRIP](https://pushpin.org/docs/protocols/grip/) is a protocol that enables a web service to
@@ -30,7 +38,7 @@ Next.js. It:
3038
* provides your route handler with tools to handle such requests, such as:
3139
* access to information about whether the current request is proxied or is signed
3240
* methods you can call to issue any instructions to the GRIP proxy
33-
* provides access to the the publisher object, enabling your application to publish messages through
41+
* provides access to the `Publisher` object, enabling your application to publish messages through
3442
the GRIP publisher.
3543

3644
Additionally, `serve-grip` also handles
@@ -152,10 +160,18 @@ middleware in a shared location and reference it from your API routes.
152160

153161
### Configuration
154162

155-
`@fanoutio/serve-grip` exports a constructor function, `ServeGrip`. This constructor takes a
163+
`@fanoutio/serve-grip/node` exports a constructor function, `ServeGrip`. This constructor takes a
156164
configuration object that can be used to configure the instance, such as the GRIP proxies to use
157165
for publishing or whether incoming requests should require a GRIP proxy.
158166

167+
> [!IMPORTANT]
168+
> `ServeGrip` is a subclass of `ServeGripBase` that works with `IncomingRequest` and `ServerResponse`
169+
> classes provided by Node.js. `ServeGrip` is also available on the main `@fanoutio/serve-grip` export
170+
> when the condition `"node"` is present when resolving imports (the default in Node.js applications).
171+
>
172+
> This design allows non-Node.js platforms (such as [Expressly](https://expressly.edgecompute.app)) to
173+
> extend `ServeGripBase` without holding a dependency on types provided by Node.js.
174+
159175
The following is an example of configuration against Pushpin running on localhost:
160176
```javascript
161177
import { ServeGrip } from '@fanoutio/serve-grip';
@@ -316,3 +332,9 @@ If you have used `express-grip` in the past, you will notice that this library n
316332
requires the use of pre-route and post-route middlewares. Consequently, you do not need to
317333
call `next()` for route handlers that complete their work. In fact, you should follow the
318334
standard practice of calling `res.end()` at the end of each of your route handlers.
335+
336+
## License
337+
338+
(C) 2015, 2020 Fanout, Inc.
339+
(C) 2024 Fastly, Inc.
340+
Licensed under the MIT License, see file LICENSE.md for details.

examples/express-http/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { ServeGrip } = require( '@fanoutio/serve-grip' );
33

44
const PORT = 3000;
55
const CHANNEL_NAME = 'test';
6-
const PUSHPIN_URL = "http://localhost:5561/";
6+
const PUSHPIN_URL = 'http://localhost:5561/';
77

88
const app = express();
99

examples/express-ws/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { WebSocketMessageFormat } = require( '@fanoutio/grip' );
44

55
const PORT = 3000;
66
const CHANNEL_NAME = 'test';
7-
const PUSHPIN_URL = "http://localhost:5561/";
7+
const PUSHPIN_URL = 'http://localhost:5561/';
88

99
const app = express();
1010

examples/koa-http/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { ServeGrip } = require( '@fanoutio/serve-grip' );
55

66
const PORT = 3000;
77
const CHANNEL_NAME = 'test';
8-
const PUSHPIN_URL = "http://localhost:5561/";
8+
const PUSHPIN_URL = 'http://localhost:5561/';
99

1010
const app = new Koa();
1111

@@ -33,7 +33,7 @@ router.get('/api/stream', ctx => {
3333
} else {
3434

3535
ctx.set('Content-Type', 'text/plain');
36-
ctx.body = "[not proxied]\n";
36+
ctx.body = '[not proxied]\n';
3737

3838
}
3939

examples/koa-ws/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { WebSocketMessageFormat } = require( '@fanoutio/grip' );
66

77
const PORT = 3000;
88
const CHANNEL_NAME = 'test';
9-
const PUSHPIN_URL = "http://localhost:5561/";
9+
const PUSHPIN_URL = 'http://localhost:5561/';
1010

1111
const app = new Koa();
1212

examples/next-http/lib/grip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ServeGrip } from "@fanoutio/serve-grip";
1+
import { ServeGrip } from '@fanoutio/serve-grip';
22

33
export const CHANNEL_NAME = 'test';
4-
const PUSHPIN_URL = "http://localhost:5561/";
4+
const PUSHPIN_URL = 'http://localhost:5561/';
55

66
export const serveGrip = new ServeGrip({
77
grip: {

examples/next-http/pages/api/publish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CHANNEL_NAME, serveGrip } from "../../lib/grip";
1+
import { CHANNEL_NAME, serveGrip } from '../../lib/grip';
22

33
export default async (req, res) => {
44

examples/next-http/pages/api/stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CHANNEL_NAME, serveGrip } from "../../lib/grip";
1+
import { CHANNEL_NAME, serveGrip } from '../../lib/grip';
22

33
export default async (req, res) => {
44

examples/next-ws/lib/grip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ServeGrip } from "@fanoutio/serve-grip";
1+
import { ServeGrip } from '@fanoutio/serve-grip';
22

33
export const CHANNEL_NAME = 'test';
4-
const PUSHPIN_URL = "http://localhost:5561/";
4+
const PUSHPIN_URL = 'http://localhost:5561/';
55

66
export const serveGrip = new ServeGrip({
77
grip: {

0 commit comments

Comments
 (0)