mirror of
https://github.com/kennethnym/aris.git
synced 2026-06-13 19:11:18 +01:00
Compare commits
1 Commits
c95c730533
...
fix-tailne
| Author | SHA1 | Date | |
|---|---|---|---|
| 000b95ccb7 |
@@ -1,45 +0,0 @@
|
|||||||
services:
|
|
||||||
expo:
|
|
||||||
name: Expo Dev Server
|
|
||||||
description: Expo development server for aelis-client
|
|
||||||
triggeredBy:
|
|
||||||
- postDevcontainerStart
|
|
||||||
commands:
|
|
||||||
start: cd apps/aelis-client && ./scripts/run-dev-server.sh
|
|
||||||
|
|
||||||
drizzle-studio:
|
|
||||||
name: Drizzle Studio
|
|
||||||
description: Drizzle Studio database browser for aelis-backend
|
|
||||||
triggeredBy:
|
|
||||||
- manual
|
|
||||||
commands:
|
|
||||||
start: |
|
|
||||||
FORWARD_URL=$(gitpod environment port open 4983 --name drizzle-studio-server | sed 's|https://||')
|
|
||||||
echo "Drizzle Studio: https://local.drizzle.studio/?host=${FORWARD_URL}&port=443"
|
|
||||||
cd apps/aelis-backend && bunx drizzle-kit studio --host 0.0.0.0 --port 4983
|
|
||||||
|
|
||||||
aelis-backend:
|
|
||||||
name: Aelis Backend
|
|
||||||
description: Hono API server for aelis-backend (port 3000)
|
|
||||||
triggeredBy:
|
|
||||||
- manual
|
|
||||||
commands:
|
|
||||||
start: |
|
|
||||||
gitpod --context environment environment port open 3000 --name "Aelis Backend" --protocol http
|
|
||||||
TS_IP=$(tailscale ip -4)
|
|
||||||
echo ""
|
|
||||||
echo "------------------ Bun Debugger ------------------"
|
|
||||||
echo "https://debug.bun.sh/#${TS_IP}:6499"
|
|
||||||
echo "------------------ Bun Debugger ------------------"
|
|
||||||
echo ""
|
|
||||||
cd apps/aelis-backend && bun run dev
|
|
||||||
|
|
||||||
admin-dashboard:
|
|
||||||
name: Admin Dashboard
|
|
||||||
description: Vite dev server for admin-dashboard (port 5174)
|
|
||||||
triggeredBy:
|
|
||||||
- manual
|
|
||||||
commands:
|
|
||||||
start: |
|
|
||||||
gitpod --context environment environment port open 5174 --name "Admin Dashboard" --protocol http
|
|
||||||
cd apps/admin-dashboard && bun run dev --host
|
|
||||||
@@ -12,6 +12,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
|
host: "0.0.0.0",
|
||||||
port: 5174,
|
port: 5174,
|
||||||
allowedHosts: true,
|
allowedHosts: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -122,5 +122,6 @@ const app = main()
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
|
hostname: "0.0.0.0",
|
||||||
fetch: app.fetch,
|
fetch: app.fetch,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import type { ServerWebSocket } from "bun"
|
import type { ServerWebSocket } from "bun"
|
||||||
|
|
||||||
const PROXY_PORT = parseInt(process.env.PROXY_PORT || "8080", 10)
|
const PROXY_PORT = parseInt(process.env.PROXY_PORT || "8080", 10)
|
||||||
|
const PROXY_HOST = process.env.PROXY_HOST || "0.0.0.0"
|
||||||
const METRO_PORT = parseInt(process.env.METRO_PORT || "8081", 10)
|
const METRO_PORT = parseInt(process.env.METRO_PORT || "8081", 10)
|
||||||
const METRO_BASE = `http://127.0.0.1:${METRO_PORT}`
|
const METRO_BASE = `http://127.0.0.1:${METRO_PORT}`
|
||||||
|
|
||||||
@@ -23,7 +24,15 @@ interface WsData {
|
|||||||
isDevice: boolean
|
isDevice: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface DebugTarget {
|
||||||
|
webSocketDebuggerUrl: string
|
||||||
|
reactNative?: {
|
||||||
|
capabilities?: { prefersFuseboxFrontend?: boolean }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bun.serve<WsData>({
|
Bun.serve<WsData>({
|
||||||
|
hostname: PROXY_HOST,
|
||||||
port: PROXY_PORT,
|
port: PROXY_PORT,
|
||||||
|
|
||||||
async fetch(req, server) {
|
async fetch(req, server) {
|
||||||
@@ -55,10 +64,11 @@ Bun.serve<WsData>({
|
|||||||
|
|
||||||
// HTTP proxy
|
// HTTP proxy
|
||||||
const upstream = `${METRO_BASE}${url.pathname}${url.search}`
|
const upstream = `${METRO_BASE}${url.pathname}${url.search}`
|
||||||
|
const body = req.body ? await req.arrayBuffer() : undefined
|
||||||
const res = await fetch(upstream, {
|
const res = await fetch(upstream, {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
headers: forwardHeaders(req.headers),
|
headers: forwardHeaders(req.headers),
|
||||||
body: req.body,
|
body,
|
||||||
redirect: "manual",
|
redirect: "manual",
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -104,14 +114,10 @@ async function printDebuggerUrl() {
|
|||||||
const res = await fetch(`${METRO_BASE}/json`)
|
const res = await fetch(`${METRO_BASE}/json`)
|
||||||
if (!res.ok) return
|
if (!res.ok) return
|
||||||
|
|
||||||
interface DebugTarget {
|
const parsedTargets: unknown = await res.json()
|
||||||
webSocketDebuggerUrl: string
|
if (!Array.isArray(parsedTargets)) return
|
||||||
reactNative?: {
|
|
||||||
capabilities?: { prefersFuseboxFrontend?: boolean }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const targets: DebugTarget[] = await res.json()
|
const targets = parsedTargets.filter(isDebugTarget)
|
||||||
const target = targets.find((t) => t.reactNative?.capabilities?.prefersFuseboxFrontend)
|
const target = targets.find((t) => t.reactNative?.capabilities?.prefersFuseboxFrontend)
|
||||||
if (!target) return
|
if (!target) return
|
||||||
|
|
||||||
@@ -124,4 +130,25 @@ async function printDebuggerUrl() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[proxy] listening on :${PROXY_PORT}, forwarding to 127.0.0.1:${METRO_PORT}`)
|
console.log(
|
||||||
|
`[proxy] listening on ${PROXY_HOST}:${PROXY_PORT}, forwarding to 127.0.0.1:${METRO_PORT}`,
|
||||||
|
)
|
||||||
|
|
||||||
|
function isDebugTarget(value: unknown): value is DebugTarget {
|
||||||
|
if (!isRecord(value) || typeof value.webSocketDebuggerUrl !== "string") return false
|
||||||
|
|
||||||
|
const reactNative = value.reactNative
|
||||||
|
if (reactNative === undefined) return true
|
||||||
|
if (!isRecord(reactNative)) return false
|
||||||
|
|
||||||
|
const capabilities = reactNative.capabilities
|
||||||
|
if (capabilities === undefined) return true
|
||||||
|
if (!isRecord(capabilities)) return false
|
||||||
|
|
||||||
|
const prefersFuseboxFrontend = capabilities.prefersFuseboxFrontend
|
||||||
|
return prefersFuseboxFrontend === undefined || typeof prefersFuseboxFrontend === "boolean"
|
||||||
|
}
|
||||||
|
|
||||||
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||||
|
return typeof value === "object" && value !== null
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ const tsIp = (await $`tailscale ip -4`.text()).trim()
|
|||||||
const base = `http://${tsIp}:${PROXY_PORT}`
|
const base = `http://${tsIp}:${PROXY_PORT}`
|
||||||
|
|
||||||
interface DebugTarget {
|
interface DebugTarget {
|
||||||
devtoolsFrontendUrl: string
|
|
||||||
webSocketDebuggerUrl: string
|
webSocketDebuggerUrl: string
|
||||||
reactNative?: {
|
reactNative?: {
|
||||||
capabilities?: {
|
capabilities?: {
|
||||||
@@ -24,7 +23,13 @@ if (!res.ok) {
|
|||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const targets: DebugTarget[] = await res.json()
|
const parsedTargets: unknown = await res.json()
|
||||||
|
if (!Array.isArray(parsedTargets)) {
|
||||||
|
console.error("Invalid /json response from Metro.")
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const targets = parsedTargets.filter(isDebugTarget)
|
||||||
const target = targets.find((t) => t.reactNative?.capabilities?.prefersFuseboxFrontend)
|
const target = targets.find((t) => t.reactNative?.capabilities?.prefersFuseboxFrontend)
|
||||||
|
|
||||||
if (!target) {
|
if (!target) {
|
||||||
@@ -50,3 +55,22 @@ try {
|
|||||||
console.log("Open the URL above in Chrome.")
|
console.log("Open the URL above in Chrome.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isDebugTarget(value: unknown): value is DebugTarget {
|
||||||
|
if (!isRecord(value) || typeof value.webSocketDebuggerUrl !== "string") return false
|
||||||
|
|
||||||
|
const reactNative = value.reactNative
|
||||||
|
if (reactNative === undefined) return true
|
||||||
|
if (!isRecord(reactNative)) return false
|
||||||
|
|
||||||
|
const capabilities = reactNative.capabilities
|
||||||
|
if (capabilities === undefined) return true
|
||||||
|
if (!isRecord(capabilities)) return false
|
||||||
|
|
||||||
|
const prefersFuseboxFrontend = capabilities.prefersFuseboxFrontend
|
||||||
|
return prefersFuseboxFrontend === undefined || typeof prefersFuseboxFrontend === "boolean"
|
||||||
|
}
|
||||||
|
|
||||||
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||||
|
return typeof value === "object" && value !== null
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
PROXY_PORT=8080
|
PROXY_PORT=8080
|
||||||
METRO_PORT=8081
|
METRO_PORT=8081
|
||||||
|
TS_IP=$(tailscale ip -4)
|
||||||
|
|
||||||
# Start a reverse proxy so Metro sees all requests as loopback.
|
# Start a reverse proxy so Metro sees all requests as loopback.
|
||||||
# This makes debugger endpoints (/debugger-frontend, /json, /open-debugger)
|
# This makes debugger endpoints (/debugger-frontend, /json, /open-debugger)
|
||||||
@@ -11,5 +12,5 @@ PROXY_PORT=$PROXY_PORT METRO_PORT=$METRO_PORT bun run scripts/dev-proxy.ts &
|
|||||||
PROXY_PID=$!
|
PROXY_PID=$!
|
||||||
trap "kill $PROXY_PID 2>/dev/null" EXIT
|
trap "kill $PROXY_PID 2>/dev/null" EXIT
|
||||||
|
|
||||||
EXPO_PACKAGER_PROXY_URL=http://$(tailscale ip -4):$PROXY_PORT bunx expo start --localhost -p $METRO_PORT
|
echo "Expo proxy: http://${TS_IP}:${PROXY_PORT}"
|
||||||
|
EXPO_PACKAGER_PROXY_URL=http://${TS_IP}:$PROXY_PORT bunx expo start --localhost -p $METRO_PORT
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"expo": "cd apps/aelis-client && bun run start",
|
||||||
|
"drizzle-studio": "TS_IP=$(tailscale ip -4); echo \"Drizzle Studio: https://local.drizzle.studio/?host=${TS_IP}&port=4983\"; cd apps/aelis-backend && bunx drizzle-kit studio --host 0.0.0.0 --port 4983",
|
||||||
|
"aelis-backend": "TS_IP=$(tailscale ip -4); echo \"Aelis Backend: http://${TS_IP}:3000\"; echo \"\"; echo \"------------------ Bun Debugger ------------------\"; echo \"https://debug.bun.sh/#${TS_IP}:6499\"; echo \"------------------ Bun Debugger ------------------\"; echo \"\"; cd apps/aelis-backend && bun run dev",
|
||||||
|
"admin-dashboard": "TS_IP=$(tailscale ip -4); echo \"Admin Dashboard: http://${TS_IP}:5174\"; cd apps/admin-dashboard && bun run dev --host 0.0.0.0",
|
||||||
"test": "bun run --filter '*' test",
|
"test": "bun run --filter '*' test",
|
||||||
"lint": "oxlint .",
|
"lint": "oxlint .",
|
||||||
"lint:fix": "oxlint --fix .",
|
"lint:fix": "oxlint --fix .",
|
||||||
|
|||||||
Reference in New Issue
Block a user