README
typed-rpc-server
Server side of typed-rpc, a Typescript library for simplifing communication between front-end and back-end.
Installing
Using npm:
$ npm install typed-rpc-server
Using yarn:
$ yarn add typed-rpc-server
Quick example
// routes.ts
export default interface Routes {
hello(str: string): string
}
// server.ts
import Routes from "./routes"
import express from "express"
import RPCServer from "typed-rpc-server"
const handler = RPCServer.create<Routes>({
routes: {
hello(str: string): string {
return "Hello " + str
}
}
})
const app = express()
app.use("/rpc", handler)
app.listen(8080)
// client.ts
import Routes from "./routes"
import RPCClient from "typed-rpc-client"
const rpc = RPCClient.create<Routes>({ url: "http://localhost:8080/rpc" })
rpc.hello("world").then((res) => {
console.log(res) // Hello world
})
Documentation
Coming soon