Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Campbell authored and Cameron Campbell committed Jul 27, 2024
2 parents aa5ade6 + 5c25e5c commit a07cd62
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/pages/guides/httpAdapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
By default Openblox uses `fetch` to make HTTP requests. Some users may prefer to use something different or are using a runtime which doesn't support fetch. For this reason Openblox facilitates the use of any of any HTTP library / framework via `HTTP Adapters`.

## Example HTTP Adapter.
```ts
```ts showLineNumbers copy
// ./myHttpAdapter.ts

// [ Modules ] ///////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -35,7 +35,7 @@ export const FetchAdapter: HttpAdapter = async ({ url, method, headers, body, fo

## Configuring Openblox To Use The Above HTTP Adapter.

```ts
```ts showLineNumbers copy
// ./index.ts
import "dotenv/config"
import { updateConfig } from "openblox/config"
Expand All @@ -48,4 +48,4 @@ updateConfig({
})

// make api requests via openblox here!
```
```
4 changes: 2 additions & 2 deletions docs/pages/guides/oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If you are looking for an incredibly simple OAuth library then [Arctic](https://

Here is a simple OAuth application using Arctic and [`Bun.serve`](https://bun.sh/docs/api/http).

```ts
```ts showLineNumbers copy
// [ Modules ] ///////////////////////////////////////////////////////////////////
import "dotenv/config";
import { OAuthApi } from "openblox/cloud";
Expand Down Expand Up @@ -149,4 +149,4 @@ const parseCookies = (cookieHeader?: string | null): Record<string, string> => {

console.log(`now serving at :${PORT}`)
})();
```
```
6 changes: 3 additions & 3 deletions docs/pages/guides/pagination.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Pagination
Openblox makes it easy to iterate over multiple pages of certain endpoints. Pagination data (such as `nextCursor` and `previousCursor`) are abstracted away from the main data and into its own `cursors` array. This cursors array is returned alongside the response data:

```ts
```ts showLineNumbers copy
const { data:userInfo, cursors } = await ClassicUsersApi.usernameHistory({ userId: 123456 })
const nextCursor = cursors.next, previousCursor = cursors.previous
```
Expand All @@ -12,7 +12,7 @@ If a method has an optional `cursor` parameter and returns `cursors` in its resu
## Example
The following example fetches a users username history across all pages.

```ts
```ts showLineNumbers copy
import "dotenv/config"
import { ClassicUsersApi } from "openblox/classic"

Expand All @@ -27,4 +27,4 @@ const USER_ID = 45348281

console.log(allPastUsernames)
})()
```
```
8 changes: 4 additions & 4 deletions docs/pages/guides/rebindingCredentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Normally, requests will use a `cookie` and `cloudKey` defined in the config (or automatically inferred from the environment variables).

```ts
```ts showLineNumbers copy
setConfig({
cookie: process.env.MY_ROBLOX_COOKIE,
cloudKey: process.env.MY_ROBLOX_CLOUD_KEY
Expand All @@ -11,7 +11,7 @@ setConfig({

However, you may want to make requests via a different `cookie` and or `cloudKey`, or maybe you want to use an `oauthToken` with your request instead. This can be done by using the `.bind` method on any Openblox wrapper method.

```ts
```ts showLineNumbers copy
const { data:classicUserInfo } = await ClassicUsersApi.userInfo.bind({ cookie: "SENSITIVE_INFO" })({ userId: 45348281 })

const { data:cloudUserInfo } = await UsersApi.userInfo.bind({ cloudKey: "SENSITIVE_INFO" })({ userId: 45348281 })
Expand All @@ -21,12 +21,12 @@ const { data:oauthUserInfo } = await OAuthApi.userInfo.bind({ oauthToken: "SENSI

You can also Assign the rebound Openblox method to a variable - this makes it easier to use the same rebound Openblox method for multiple requests.

```ts
```ts showLineNumbers copy
const Rebound_ClassicUsersApi_userInfo = ClassicUsersApi.userInfo.bind({ cookie: "SENSITIVE_INFO" })
const Rebound_UsersApi_userInfo = UsersApi.userInfo.bind({ cloudKey: "SENSITIVE_INFO" })
const Rebound_OAuthApi_userInfo = OAuthApi.userInfo.bind({ oauthToken: "SENSITIVE_INFO" })

const { data:classicUserInfo } = Rebound_ClassicUsersApi_userInfo({ userId: 45348281 })
const { data:cloudUserInfo } = Rebound_UsersApi_userInfo({ userId: 45348281 })
const { data:oauthUserInfo } = Rebound_OAuthApi_userInfo()
```
```
4 changes: 2 additions & 2 deletions docs/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ It wraps over 100+ Roblox API endpoints, each with its own strictly typed respon

<h3>Example Usage</h3>

```ts
```ts showLineNumbers copy
import "dotenv/config";
import { setConfig } from "openblox/config";
import { UsersApi } from "openblox/cloud";
Expand All @@ -42,4 +42,4 @@ setConfig({
const { data:userInfo_cloud } = await UsersApi.userInfo({ userId: 45348281 })

})
```
```

0 comments on commit a07cd62

Please sign in to comment.