Skip to content

Commit

Permalink
docs(README): fix usage examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Dec 9, 2022
1 parent dfb9db8 commit 5532c30
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Expand Up @@ -673,6 +673,7 @@ The `app.webhooks.*` APIs provide methods to receiving, verifying, and handling
Example: create a comment on new issues

```js
import { createServer } from "node:http":
import { App, createNodeMiddleware } from "octokit";

const app = new App({
Expand All @@ -690,7 +691,7 @@ app.webhooks.on("issues.opened", ({ octokit, payload }) => {
});

// Your app can now receive webhook events at `/api/github/webhooks`
require("http").createServer(createNodeMiddleware(app)).listen(3000);
createServer(createNodeMiddleware(app)).listen(3000);
```

For serverless environments, you can explicitly verify and receive an event
Expand Down Expand Up @@ -723,6 +724,7 @@ There are some differences:
Example: Watch a repository when a user logs in using the OAuth web flow

```js
import { createServer } from "node:http":
import { App, createNodeMiddleware } from "octokit";

const app = new App({
Expand All @@ -739,7 +741,7 @@ app.oauth.on("token.created", async ({ token, octokit }) => {

// Your app can receive the OAuth redirect at /api/github/oauth/callback
// Users can initiate the OAuth web flow by opening /api/oauth/login
require("http").createServer(createNodeMiddleware(app)).listen(3000);
createServer(createNodeMiddleware(app)).listen(3000);
```

For serverless environments, you can explicitly exchange the `code` from the OAuth web flow redirect for an access token.
Expand Down Expand Up @@ -767,6 +769,7 @@ const { token } = await app.oauth.createToken({
Example: Create an OAuth App Server with default scopes

```js
import { createServer } from "node:http":
import { OAuthApp, createNodeMiddleware } from "octokit";

const app = new OAuthApp({
Expand All @@ -787,7 +790,7 @@ app.oauth.on("token", async ({ token, octokit }) => {

// Your app can receive the OAuth redirect at /api/github/oauth/callback
// Users can initiate the OAuth web flow by opening /api/oauth/login
require("http").createServer(createNodeMiddleware(app)).listen(3000);
createServer(createNodeMiddleware(app)).listen(3000);
```

### App Server
Expand Down

0 comments on commit 5532c30

Please sign in to comment.