Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: render frame nextjs api docs #281

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/two-hairs-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"docs": patch
---

docs: render frame nextjs api docs
27 changes: 27 additions & 0 deletions docs/pages/reference/render/next/get.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
# GET

Fetches HTML content from a given URL and attempts to extract a frame from it.

## Usage

```tsx [./frames/route.tsx]
export { GET, POST } from "@frames.js/render/next';
```

### Request

- **URL Query Parameters:**
- `url` (required): The URL from which the HTML content is to be fetched.

### Response

Depending on the outcome of the fetch and frame extraction process, the response can vary:

- **Success:**
- Returns a JSON object containing the extracted frame data and any errors encountered during the frame extraction process.
- **Invalid URL:**

- If the `url` parameter is missing or invalid, returns a JSON object with a `message` indicating "Invalid URL" and a status code of 400.

- **Fetch or Processing Errors:**
- In case of errors during the fetch operation or frame extraction, returns a JSON object with a `message` detailing the error and a status code of 500.

### Errors

Errors are communicated through the status codes and messages in the JSON response:

- **400 Bad Request:** Indicates that the required `url` query parameter is missing or invalid.
- **500 Internal Server Error:** Indicates an error during the fetch operation or while processing the fetched content.
32 changes: 32 additions & 0 deletions docs/pages/reference/render/next/post.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
# POST

Proxies a POST request to the specified `postUrl` with the payload provided in the request body.

## Usage

```tsx [./frames/route.tsx]
export { GET, POST } from "@frames.js/render/next';
```

### Request

- **URL Query Parameters:**

- `postType` (optional): A string indicating the type of the POST request. It can be either `post_redirect` to handle redirects manually or `tx` for transaction requests.
- `postUrl` (required): The URL to which the POST request should be proxied.

- **Body:** JSON payload conforming to the `FrameActionPayload` structure imported from `frames.js`.

### Response

The response varies depending on the `postType` and the status of the request to the `postUrl`.

- **For a 302 status code from `postUrl`:**

- Returns a JSON object containing the `location` header value from the response, with a status code of 302.

- **For `postType` of `tx`:**

- Returns the JSON response received from the `postUrl`.

- **For other responses:**
- Attempts to extract a frame from the HTML content returned by the `postUrl`, using the `getFrame` function from `frames.js`. Returns a JSON object containing the frame data and any errors encountered during the frame extraction process.

### Errors

- Returns a response generated by `Response.error()` in case of:
- Absence of the `postUrl` parameter in the request.
- Any fetch operation or processing errors.
Loading