Skip to content

Commit

Permalink
more compact API reference
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Dec 11, 2024
1 parent 36fccfb commit dbd8c3e
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions frontend/src/components/APISection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,20 @@ const APISection: React.FC = () => {
request: '{chainId, compact: Compact}',
response: '{hash, signature, nonce}',
},
{
method: 'GET',
path: '/compact/:chainId/:claimHash',
response: '{chainId, hash, compact: Compact, signature, createdAt}',
},
{
method: 'GET',
path: '/compacts',
response: '[{chainId, hash, compact: Compact, signature, createdAt}]',
},
{
method: 'GET',
path: '/compact/:chainId/:claimHash',
response: '{chainId, hash, compact: Compact, signature, createdAt}',
path: '/suggested-nonce/:chainId',
response: '{nonce}',
},
{
method: 'GET',
Expand All @@ -77,32 +82,25 @@ const APISection: React.FC = () => {
response:
'{balances: [{chainId, lockId, allocatableBalance, allocatedBalance, balanceAvailableToAllocate, withdrawalStatus: number}]}',
},
{
method: 'GET',
path: '/suggested-nonce/:chainId',
response: '{nonce}',
},
],
};

return (
<div className="mx-auto p-6 bg-[#0a0a0a] rounded-lg shadow-xl border border-gray-800">
<h2 className="text-xl font-bold text-white text-xl mb-1">
API Reference
</h2>
<div className="text-gray-400 mb-4 text-sm">
<div className="mx-auto p-4 bg-[#0a0a0a] rounded-lg shadow-xl border border-gray-800">
<h2 className="text-lg font-bold text-white mb-0.5">API Reference</h2>
<div className="text-gray-400 mb-3 text-xs">
All fields are of type `string` unless indicated otherwise. Arguments
ending in ? are optional.
</div>

{/* Type Definitions */}
<div className="mb-6 space-y-2">
<h3 className="text-lg font-semibold text-[#00ff00] mb-2">
<div className="mb-4 space-y-1">
<h3 className="text-[0.95rem] font-semibold text-[#00ff00] mb-1">
Type Definitions
</h3>
{Object.entries(typeDefinitions).map(([name, definition]) => (
<div key={name} className="font-mono text-sm space-y-1">
<div className="flex items-start gap-1">
<div key={name} className="font-mono text-xs">
<div className="flex items-baseline gap-1">
<span className="text-purple-400 font-semibold">{name}</span>
<span className="text-gray-500">=</span>
<span className="text-gray-400">{definition}</span>
Expand All @@ -112,13 +110,13 @@ const APISection: React.FC = () => {
</div>

{/* Endpoints */}
<div className="space-y-6">
<div className="space-y-4">
{Object.entries(endpoints).map(([category, endpoints]) => (
<div key={category}>
<h3 className="text-lg font-semibold text-[#00ff00] mb-0">
<h3 className="text-[0.95rem] font-semibold text-[#00ff00] mb-0.5">
{category} Endpoints
{category === 'Authenticated' && (
<span className="text-sm font-normal text-gray-400 ml-2">
<span className="text-xs font-normal text-gray-400 ml-2">
(requires{' '}
<code className="bg-gray-800 px-1 rounded">
x-session-id: session
Expand All @@ -127,19 +125,19 @@ const APISection: React.FC = () => {
</span>
)}
</h3>
<div className="space-y-3">
<div className="space-y-1.5">
{endpoints.map((endpoint, index) => (
<div
key={index}
className="font-mono text-sm space-y-1 hover:bg-gray-900 p-0 rounded"
className="font-mono text-xs hover:bg-gray-900 rounded"
>
<div className="flex items-start gap-2">
<div className="flex items-baseline gap-1.5">
<span
className={`
${endpoint.method === 'GET' ? 'text-blue-400' : ''}
${endpoint.method === 'POST' ? 'text-green-400' : ''}
${endpoint.method === 'DELETE' ? 'text-red-400' : ''}
font-semibold min-w-[4rem] w-[4rem]
font-semibold min-w-[3.5rem] w-[3.5rem]
`}
>
{endpoint.method}
Expand All @@ -157,7 +155,7 @@ const APISection: React.FC = () => {
<span className="text-gray-400">{endpoint.response}</span>
</div>
{endpoint.args && (
<div className="pl-20 text-xs space-y-1">
<div className="pl-16 text-[0.7rem] space-y-0.5">
{endpoint.args.map((arg, i) => (
<div key={i} className="text-gray-500">
{arg}
Expand Down

0 comments on commit dbd8c3e

Please sign in to comment.