Skip to content
Open
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
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

old_docs
.superpowers
# superpowers plans/specs are local working artifacts — never version them.
# (astro-migration files already tracked on main stay tracked; gitignore does
# not affect already-tracked files.)
docs/superpowers/*
!docs/superpowers/specs/
!docs/superpowers/specs/**
!docs/superpowers/plans/
!docs/superpowers/plans/**
.claude/worktrees
.worktrees

Expand Down
60 changes: 60 additions & 0 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,61 @@ import { prebuildSkills } from './src/integrations/prebuild-skills'
const REGION = process.env['VITE_REGION'] ?? 'global'
const SITE = process.env['VITE_SITE_HOSTNAME'] ?? 'https://open.longportapp.com'

// Dev-only reverse proxy for the TryIt debugger. Vite's built-in http-proxy
// returns 502 for these HTTPS upstreams under bun, so forward with fetch (which
// works). `/api-prod` → production gateway.
function apiDevProxy() {
const TARGETS: Record<string, string> = {
'/api-prod': 'https://openapi.longbridge.com',
// Legacy default prefix used by <TryIt> when no baseUrl is passed.
'/api': 'https://openapi.longbridge.com',
}
return {
name: 'lb-api-dev-proxy',
apply: 'serve' as const,
configureServer(server: { middlewares: { use: (fn: (req: any, res: any, next: () => void) => void) => void } }) {
// Dev only: corporate networks MITM these HTTPS upstreams with a cert the
// dev process doesn't trust, so outbound fetch fails. Skip verification —
// this never runs in a production build (apply: 'serve').
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'
server.middlewares.use(async (req: any, res: any, next: () => void) => {
const url: string = req.url ?? ''
const prefix = Object.keys(TARGETS).find((p) => url === p || url.startsWith(p + '/'))
if (!prefix) return next()
const target = TARGETS[prefix]
const path = url.slice(prefix.length) || '/'
try {
const chunks: Buffer[] = []
for await (const c of req) chunks.push(c as Buffer)
const method: string = (req.method ?? 'GET').toUpperCase()
const headers: Record<string, string> = {}
for (const [k, v] of Object.entries(req.headers)) {
if (k === 'host' || k === 'connection' || k === 'content-length') continue
if (typeof v === 'string') headers[k] = v
}
const upstream = await fetch(target + path, {
method,
headers,
body: method === 'GET' || method === 'HEAD' || chunks.length === 0 ? undefined : Buffer.concat(chunks),
})
res.statusCode = upstream.status
upstream.headers.forEach((value: string, key: string) => {
const k = key.toLowerCase()
// Body is already decoded by fetch — don't forward encoding/length.
if (k === 'content-encoding' || k === 'content-length' || k === 'transfer-encoding') return
res.setHeader(key, value)
})
res.end(Buffer.from(await upstream.arrayBuffer()))
} catch (err) {
res.statusCode = 502
res.setHeader('content-type', 'application/json; charset=utf-8')
res.end(JSON.stringify({ code: -1, msg: `dev proxy error: ${err instanceof Error ? err.message : String(err)}`, data: null }))
}
})
},
}
}

export default defineConfig({
site: SITE,
// `assets: 'assets'` (default is `_astro`) so hashed CSS/JS land in /assets/ —
Expand All @@ -44,6 +99,11 @@ export default defineConfig({
],
vite: {
plugins: [
// Dev proxy for the API Reference TryIt debugger: one prefix per
// environment so the 生产/测试 toggle can hit either backend without CORS.
// Implemented with fetch (not Vite's http-proxy, which 502s under bun for
// these HTTPS upstreams). Dev only — prod talks to the real domains.
apiDevProxy(),
tailwind(),
// Rename mdx frontmatter `layout:` → `docs_layout:` so astro-mdx
// doesn't try to resolve values like "api-reference" as module
Expand Down
8 changes: 8 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

241 changes: 0 additions & 241 deletions docs/en/docs/account/alert/update_alert.mdx

This file was deleted.

1 change: 0 additions & 1 deletion docs/en/docs/account/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Create and manage price alerts for securities.
|---|---|
| [list_alerts](./alert/list-alerts) | List all active price alerts |
| [create_alert](./alert/create-alert) | Create a new price alert |
| [update_alert](./alert/update-alert) | Update an existing alert |
| [delete_alert](./alert/delete-alert) | Delete a price alert |

## DCAContext
Expand Down
Loading
Loading