feat: restructure API and documentation with new relay handler and UI components
This commit is contained in:
@@ -4,8 +4,9 @@ HTTP proxy untuk Vercel Edge Runtime.
|
|||||||
|
|
||||||
## Live Deployment
|
## Live Deployment
|
||||||
|
|
||||||
Endpoint utama: `https://proxy-bun.vercel.app/api/relay`
|
- **API Endpoint**: `https://proxy-bun.vercel.app/`
|
||||||
Endpoint kedua: `https://vercel-relay-bgddcbfit-asepharyana71s-projects.vercel.app`
|
- **Docs/Tester**: `https://proxy-bun.vercel.app/docs`
|
||||||
|
|
||||||
## Cara Pakai
|
## Cara Pakai
|
||||||
|
|
||||||
### Header yang Dibutuhkan
|
### Header yang Dibutuhkan
|
||||||
@@ -19,12 +20,12 @@ Endpoint kedua: `https://vercel-relay-bgddcbfit-asepharyana71s-projects.vercel.a
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Proxy
|
# Proxy
|
||||||
curl -H "x-relay-target: https://jsonplaceholder.typicode.com/posts/1" https://proxy-bun.vercel.app/api/relay
|
curl -H "x-relay-target: https://jsonplaceholder.typicode.com/posts/1" https://proxy-bun.vercel.app/
|
||||||
|
|
||||||
# Proxy ke endpoint spesifik
|
# Proxy ke endpoint spesifik
|
||||||
curl -H "x-relay-target: https://api.example.com" \
|
curl -H "x-relay-target: https://api.example.com" \
|
||||||
-H "x-relay-path: /v1/users" \
|
-H "x-relay-path: /v1/users" \
|
||||||
https://proxy-bun.vercel.app/api/relay
|
https://proxy-bun.vercel.app/
|
||||||
```
|
```
|
||||||
|
|
||||||
### HTTP Methods
|
### HTTP Methods
|
||||||
@@ -57,7 +58,8 @@ HTTP 400 jika `x-relay-target` tidak ada.
|
|||||||
proxy-bun/
|
proxy-bun/
|
||||||
├── src/
|
├── src/
|
||||||
│ ├── app/
|
│ ├── app/
|
||||||
│ │ └── api/relay/route.ts # Edge handler
|
│ │ ├── docs/page.tsx # UI / Documentation
|
||||||
|
│ │ └── route.ts # Edge API handler
|
||||||
│ └── lib/
|
│ └── lib/
|
||||||
│ ├── relay-utils.ts # Pure functions untuk relay logic
|
│ ├── relay-utils.ts # Pure functions untuk relay logic
|
||||||
│ └── relay-utils.test.ts # Unit tests
|
│ └── relay-utils.test.ts # Unit tests
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export default function Home() {
|
|||||||
fetchOptions.body = requestBody;
|
fetchOptions.body = requestBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await fetch('/api/relay', fetchOptions);
|
const res = await fetch('/', fetchOptions);
|
||||||
const elapsed = Date.now() - start;
|
const elapsed = Date.now() - start;
|
||||||
|
|
||||||
let responseText = '';
|
let responseText = '';
|
||||||
Reference in New Issue
Block a user