Skip to content

Commit

Permalink
feat: v14 (#409)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `onUnhandledRequest` middleware option is removed
BREAKING CHANGE: Drop support for NodeJS v14, v16
BREAKING CHANGE: Replace support for Node.js http(s) Agents with documentation on using fetch dispatchers instead (via `@octokit/request`)
BREAKING CHANGE: Remove ability to pass custom request options, except from `method`, `headers`, `body`, `signal` (via `@octokit/request`)
  • Loading branch information
wolfy1339 committed Jul 10, 2023
1 parent 0a4954d commit b329da2
Show file tree
Hide file tree
Showing 8 changed files with 465 additions and 477 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ jobs:
strategy:
matrix:
node_version:
- 14
- 16
- 18
- 20
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node_version }}
Expand Down
40 changes: 13 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ Middleware for Node's built in http server or [`express`](https://expressjs.com/

```js
const { App, createNodeMiddleware } = require("@octokit/app");

const app = new App({
appId: 123,
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
Expand All @@ -337,11 +338,20 @@ const app = new App({
});

const middleware = createNodeMiddleware(app);

require("http").createServer(middleware).listen(3000);
require("http")
.createServer(async (req, res) => {
// `middleware` returns `false` when `req` is unhandled (beyond `/api/github`)
if (await middleware(req, res)) return;
res.writeHead(404);
res.end();
})
.listen(3000);
// can now receive user authorization callbacks at /api/github/*
```

The middleware returned from `createNodeMiddleware` can also serve as an
`Express.js` middleware directly.

<table width="100%">
<thead align=left>
<tr>
Expand Down Expand Up @@ -392,33 +402,9 @@ All exposed paths will be prefixed with the provided prefix. Defaults to `"/api/

Used for internal logging. Defaults to [`console`](https://developer.mozilla.org/en-US/docs/Web/API/console) with `debug` and `info` doing nothing.

</td>
</td>
</tr>
<tr>
<th>
<code>options.onUnhandledRequest</code>
</th>
<th>
<code>function</code>
</th>
<td>

Defaults to

```js
function onUnhandledRequest(request, response) {
response.writeHead(400, {
"content-type": "application/json",
});
response.end(
JSON.stringify({
error: error.message,
}),
);
}
```

</td></tr>
</tbody>
</table>

Expand Down

0 comments on commit b329da2

Please sign in to comment.