Seamless integration
Write functions on the server. Call those functions from the client, types included. Don't waste time designing and maintaining your endpoints.
Seamless API integration with E2E integrity.
Convert your functions into an API server plus a type-safe client in just 2 lines of code.
import { createServer } from 'node:http'
import { createController } from 'integro'
export const app = {
version: () => '0.5.0',
greetings: {
sayHey: (name: string) => `Hey, ${name}!`,
},
}
createServer(createController(app)).listen()
import { createClient } from 'integro/client'
import type { app } from './app'
export const api = createClient<typeof app>()
console.log(await api.version())
// -> "0.5.0"
console.log(await api.greetings.sayHey('Babe'))
// -> "Hey, Babe!"
console.log(await api.greetings('Babe')) // Error: This expression is not callable.
console.log(await api.greetings.sayHey(666)) // Error: Argument of type 'number' is not assignable to parameter of type 'string'.