Skip to content

Commit

Permalink
local proxy test
Browse files Browse the repository at this point in the history
  • Loading branch information
dsoskey committed May 23, 2024
1 parent 981e881 commit 86b0705
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
1 change: 1 addition & 0 deletions config/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const config: ClientConfig = {
displayTypes: false,
docsUpdate: true,
edhrecOverlay: false,
proxyTest: true,
}
}

Expand Down
3 changes: 2 additions & 1 deletion config/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const FLAG_NAMES = {
showDebugInfo: 'showDebugInfo',
displayTypes: 'displayTypes',
docsUpdate: 'docsUpdate',
edhrecOverlay: 'edhrecOverlay'
edhrecOverlay: 'edhrecOverlay',
proxyTest: 'proxyTest',
} as const
export type Flag = ObjectValues<typeof FLAG_NAMES>
3 changes: 2 additions & 1 deletion config/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const config: ClientConfig = {
adminMode: false,
displayTypes: false,
docsUpdate: false,
edhrecOverlay: false
edhrecOverlay: false,
proxyTest: false,
}
}

Expand Down
36 changes: 33 additions & 3 deletions src/ui/notFoundView.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
import React from 'react'
import React, { useContext, useState } from 'react'
import { Link } from 'react-router-dom'
import { FlagContext } from './flags'

export interface NotFoundViewProps {

}

export function NotFoundView({}: NotFoundViewProps) {
return <div>
<h1>Whoa there, buddy!</h1>
const { proxyTest } = useContext(FlagContext).flags;

return <div>
<h2>Whoa there, buddy!</h2>
<p>looks like you found yourself in a bit of a situation. Maybe hit the back button or <Link to='/'>go to the search page</Link>?</p>

{proxyTest && <ProxyTest />}
</div>;
}

function ProxyTest() {
const [result, setResult] = useState<any>()
const [port, setPort] = useState<number>(6969);

const runTest = () => {
setResult(undefined);
(async () => {
try {
const nextResult = await fetch(`http://localhost:${port}/ping`);
const text = await nextResult.text();
setResult(text)
} catch (e) {
console.error(e);
setResult(e);
}
})()
}

return <div>
<h3>port check!</h3>
<input type='number' value={port} onChange={e => setPort(parseInt(e.target.value))} />
<button onClick={runTest}>test</button>
{result && <pre><code>{result.toString()}</code></pre>}
</div>
}

0 comments on commit 86b0705

Please sign in to comment.