Skip to content

polyapi/perch-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

perch-ts 🦜

The TypeScript client for PolyAPI. perch-ts uses a JavaScript Proxy to dynamically route function calls to the PolyAPI backend — no code generation, no bloat.


Installation

# npm
npm install polyapi-perch

# pnpm
pnpm add polyapi-perch

# yarn
yarn add polyapi-perch

How it works

perch-ts creates a recursive Proxy object that intercepts property access and function calls. Each call is serialized and dispatched to the PolyAPI backend at runtime — the client itself has no knowledge of your specific API surface.

your code
    │
    ▼
poly.namespace.functionName(args)
    │
    │  Proxy intercepts call, builds request:
    │  { path: ["namespace", "functionName"], args }
    │
    ▼
PolyAPI backend
    │
    ▼
response

This means:

  • Faster server function executions
  • No generated stubs to keep in sync
  • New client functions are available without a redepoly
  • The full API surface is available from a single set of imports

Quickstart

Call a function

Property access builds the path; calling it dispatches to the backend.

import poly from 'polyapi-perch';

// Calls: POST /execute/send-email/notify-user
const result = await poly.sendEmail.notifyUser({
  to: '[email protected]',
  subject: 'Hello from perch',
})

Nested namespaces

import poly from 'polyapi-perch';

const report = await poly.reporting.finance.generateQuarterly({ quarter: 'Q3' })

About

The TypeScript runtime client for PolyAPI server functions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors