Entity-First Abstraction Protocol
URPC
Solve Data Heterogeneity with Entity-First Abstraction
A protocol focused on entity-first abstraction, aimed at resolving same-domain, cross-source complexity. Kill switch-case hell in multi-protocol apps with unified entity models.
import { URPC } from "@unilab/urpc-hono";
import { MastraPlugin } from "@unilab/mastra-plugin/hono";
import { Logging } from "@unilab/urpc-core/middleware";
import { UserEntity } from "./entities/user";
// import { UserAdapter } from "./adapters/user";
import { MockAdapter } from "@unilab/urpc-adapters";
const MyPlugin = {
entities: [UserEntity],
// adapters: [{ entity: "UserEntity", source: "demo", adapter: new UserAdapter()}],
};
const app = URPC.init({
plugins: [
MyPlugin,
MastraPlugin({
defaultModel: "openai/gpt-4o-mini",
openrouterApiKey: process.env.OPENROUTER_API_KEY,
debug: true,
})
],
middlewares: [Logging()],
entityConfigs: {
user: {
defaultSource: "mock",
},
},
globalAdapters: [MockAdapter],
});
export default {
port: 3000,
fetch: app.fetch,
};