-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c2b2d0
commit e66d904
Showing
7 changed files
with
107 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// /examples/node/axios.ts | ||
// Uses `axios` to hit the GitHub API. | ||
|
||
import axios from 'axios' | ||
import { getRateLimit } from 'ratelimit-header-parser' | ||
|
||
// Make a GET request to the GitHub API. | ||
const response = await axios('https://api.github.com/orgs/express-rate-limit') | ||
console.log('github ratelimit:', getRateLimit(response)) | ||
|
||
// > github ratelimit: { limit: 60, used: 1, remaining: 59, reset: 2023-08-25T04:16:48.000Z } |
2 changes: 1 addition & 1 deletion
2
examples/draft-7-fetch.example.ts → examples/node/draft-7-fetch.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// /examples/node/http-get.ts | ||
// Uses `http.get` to hit the Imgur API. | ||
|
||
import https from 'node:https' | ||
import { getRateLimit } from 'ratelimit-header-parser' | ||
|
||
// Make a GET request to the Imgur API. | ||
https.get('https://api.imgur.com/post/v1/posts/t/aww', (response) => { | ||
console.log('imgur ratelimit:', getRateLimit(response)) | ||
|
||
return response.resume() | ||
}) | ||
|
||
// > imgur ratelimit: { limit: 500, used: 1, remaining: 499, reset: 2023-09-19T14:19:30.297Z } |
11 changes: 5 additions & 6 deletions
11
examples/github-fetch.example.ts → examples/node/native-fetch.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
// /examples/github-fetch.example.ts | ||
// Uses `fetch` to hit the Github API. | ||
// /examples/node/native-fetch.ts | ||
// Uses `fetch` to hit the GitHub API. | ||
|
||
import { getRateLimit } from 'ratelimit-header-parser' | ||
|
||
const response = await fetch( | ||
'https://api.github.com/repos/express-rate-limit/express-rate-limit/contributors?anon=1', | ||
) | ||
|
||
// Make a GET request to the GitHub API. | ||
const response = await fetch('https://api.github.com/orgs/express-rate-limit') | ||
console.log('github ratelimit:', getRateLimit(response)) | ||
|
||
// > github ratelimit: { limit: 60, used: 1, remaining: 59, reset: 2023-08-25T04:16:48.000Z } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters