feat(samples): add TypeScript backend using Grid TypeScript SDK#197
feat(samples): add TypeScript backend using Grid TypeScript SDK#197pengying wants to merge 1 commit into02-12-feat_adding_kotlin_samplefrom
Conversation
Express server mirroring the Kotlin sample with the same API contract. Uses @lightsparkdev/grid SDK, tsx runtime, and serves the shared React frontend. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Greptile OverviewGreptile SummaryThis PR adds a TypeScript backend sample that mirrors the Kotlin implementation using the Grid TypeScript SDK. The implementation provides Express-based REST endpoints for customer creation, external account linking, quote management, and sandbox operations, along with webhook streaming via Server-Sent Events.
Minor issues found:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| samples/typescript/src/gridClient.ts | Initializes Grid SDK client with API credentials |
| samples/typescript/src/index.ts | Express server setup with API routes and SSE streaming; contains wildcard route syntax error on line 86 |
| samples/typescript/src/routes/customers.ts | Customer creation endpoint using Grid SDK |
| samples/typescript/src/routes/quotes.ts | Quote creation and execution endpoints using Grid SDK |
| samples/typescript/src/routes/webhooks.ts | Webhook receiver endpoint with TODO for signature verification |
| samples/typescript/tsconfig.json | TypeScript configuration with bundler moduleResolution (consider using node16 for Node.js) |
Sequence Diagram
sequenceDiagram
participant Browser
participant Express as Express Backend
participant SDK as Grid TypeScript SDK
participant API as Grid API
Note over Browser,API: Payout Flow
Browser->>Express: POST /api/customers
Express->>SDK: gridClient.customers.create()
SDK->>API: POST /customers
API-->>SDK: Customer response
SDK-->>Express: Customer object
Express-->>Browser: 201 Created
Browser->>Express: POST /api/customers/:id/external-accounts
Express->>SDK: gridClient.customers.externalAccounts.create()
SDK->>API: POST /customers/:id/external-accounts
API-->>SDK: ExternalAccount response
SDK-->>Express: ExternalAccount object
Express-->>Browser: 201 Created
Browser->>Express: POST /api/quotes
Express->>SDK: gridClient.quotes.create()
SDK->>API: POST /quotes
API-->>SDK: Quote response
SDK-->>Express: Quote object
Express-->>Browser: 201 Created
Browser->>Express: POST /api/quotes/:id/execute
Express->>SDK: gridClient.quotes.execute()
SDK->>API: POST /quotes/:id/execute
API-->>SDK: Quote execution response
SDK-->>Express: Updated quote
Express-->>Browser: 200 OK
Browser->>Express: POST /api/sandbox/send-funds
Express->>SDK: gridClient.sandbox.sendFunds()
SDK->>API: POST /sandbox/send
API-->>SDK: Transaction response
SDK-->>Express: Transaction object
Express-->>Browser: 200 OK
Note over Browser,API: Webhook Streaming
API->>Express: POST /api/webhooks (webhook event)
Express->>Express: webhookStream.addEvent()
Express-->>API: 200 OK
Browser->>Express: GET /api/sse (EventSource)
Express-->>Browser: SSE: connected
Express-->>Browser: SSE: replay buffered events
Express->>Browser: SSE: stream new webhook events
Last reviewed commit: f0dbb39
| "compilerOptions": { | ||
| "target": "ES2022", | ||
| "module": "ESNext", | ||
| "moduleResolution": "bundler", |
There was a problem hiding this comment.
moduleResolution: "bundler" is intended for bundlers like Vite/esbuild. For Node.js with tsx, use "node" or "node16":
| "moduleResolution": "bundler", | |
| "moduleResolution": "node16", |
Prompt To Fix With AI
This is a comment left during a code review.
Path: samples/typescript/tsconfig.json
Line: 5:5
Comment:
`moduleResolution: "bundler"` is intended for bundlers like Vite/esbuild. For Node.js with `tsx`, use `"node"` or `"node16"`:
```suggestion
"moduleResolution": "node16",
```
How can I resolve this? If you propose a fix, please make it concise.
Add TypeScript backend sample for Grid API
Add a TypeScript (Express) backend implementation that mirrors the existing Kotlin sample with the same API contract. This implementation:
@lightsparkdev/gridTypeScript SDK to interact with the Grid API/publicdirectoryThe implementation uses modern ES modules, the tsx runtime for TypeScript execution, and proper error handling throughout.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com