ttc-origin-server
v0.10.0
Published
A lightweight server for TTC Origins - run RPC services with decorator-based endpoints
Downloads
2,271
Maintainers
Readme
TTC Origin Server
A lightweight server wrapper for ttc-rpc that exposes your decorated classes as RPC endpoints with automatic API discovery.
Installation
bun add ttc-origin-server
# or
npm install ttc-origin-serverQuick Start
- Create a module using
ttc-rpcdecorators
// src/test.ts
import { ttc } from "ttc-rpc";
import z from "zod";
export class HelloWorldModule {
@ttc.describe({
doc: 'some info',
inputSchema: z.object({
name: z.string()
}),
outputSchema: z.string(),
validate: true,
auth: true
})
hello(name: string): string {
return `Hello, ${name}!`;
}
}- Start the server
// src/index.ts
import { runServer } from 'ttc-origin-server';
import { HelloWorldModule } from './test';
runServer({
name: 'my-service',
modules: [HelloWorldModule],
port: 3000,
authCb: async (req) => {
// Your authentication logic
return true;
}
});- Run
bun run src/index.tsAPI
runServer(config)
Starts a TTC Origin server.
Config options:
name(string) – Service namemodules(any[]) – Array of classes decorated with@ttc.describeport(number) – Port to listen onauthCb(req => Promise) – Authentication callbackapp(express.Express) – Optional existing Express apprequireAuth(boolean) – Whether authentication is requiredmodifyable(boolean) – Iftrue, exposes working directorydescription(string) – Optional description
Endpoints
GET /rpc/info– Service metadataGET /rpc/functions– Lists all RPC methods (auto‑discovered)POST /rpc/:module/:method– Invoke an RPC method (handled byttc-rpc)
Decorator Usage
Refer to the ttc-rpc npm package for full documentation on the @ttc.describe decorator and its options.
Development
git clone https://github.com/tentarcles/ttc-origin-server.git
cd ttc-origin-server
bun install
bun run devLicense
MIT © Tentarcles
