Type-safe API contracts (HTTP/WebSocket) with adapters, client and docs generator.
npm install @codexsploitx/schemaapi
Website •
Quick Start •
Adapters •
Docs




Build type-safe APIs at the speed of thought.
Define your contract once. Generate Backend Controllers, Frontend SDKs, and Documentation instantly.
---
SchemaApi isn't just a validation library. It's an Architecture.
By defining a Single Source of Truth (Contract), you eliminate the disconnect between your Backend and Frontend.
| ❌ Traditional | ✅ SchemaApi |
| :--- | :--- |
| Write Controllers manually | Auto-generated strict controllers |
| Write types.ts manually | Types inferred from schema |
| Write Frontend Fetch calls | Auto-generated Typed SDK |
| Update Swagger manually | Auto-generated Documentation |
| "It works on my machine" | "It adheres to the contract" |
---
| 🛡️ End-to-End Type Safety | ⚡ Runtime Validation | 🔌 Adapter Agnostic |
| :--- | :--- | :--- |
| Your Backend types ARE your Frontend types. Zero duplication. | Powered by Zod. If the data is wrong, the request never hits your logic. | Works with Express, Next.js, Fastify, NestJS, Remix, and more. |
| 📦 Zero-Config SDK | 🚀 Instant Mocking | 📚 Live Documentation |
| :--- | :--- | :--- |
| Frontend devs get a fully typed client. client.users.get({ id }) | Start frontend work before the backend is even written. | Beautiful HTML docs generated from your contracts. |
---
Go from Zero to Production-Ready API in 30 seconds.
bash
npx @codexsploitx/schemaapi init express
`$3
`bash
npx @codexsploitx/schemaapi generate resource users
`$3
`bash
npx @codexsploitx/schemaapi generate sdk users
`That's it. You now have:
-
contracts/usersContract.ts: The definition.
- src/routes/users.ts: The backend implementation.
- src/sdk/usersClient.ts: The frontend client.---
🧩 The Ecosystem (Adapters)
SchemaApi plays nice with everyone. Use the CLI to drop into any stack.
| Stack | Status | CLI Command |
| :--- | :---: | :--- |
|
Express | 🟢 Stable |
npx ... init express |
|
Next.js | 🟢 Stable | npx ... init next |
|
Fastify | 🟢 Stable | npx ... init fastify |
|
Remix | 🟢 Stable | npx ... init remix |
|
NestJS | 🟢 Stable | npx ... init nest |
|
Deno | 🟢 Stable | npx ... init deno |
|
Koa/Hapi| 🟡 Beta | npx ... init koa |---
🛠️ Usage Example
$3
This is the Law.`typescript
import { createContract } from "@codexsploitx/schemaapi";
import { z } from "zod";export const postContract = createContract({
name: "posts",
routes: {
"GET /posts/:id": {
params: z.object({ id: z.string().uuid() }),
responses: {
200: z.object({ id: z.string(), title: z.string() }),
404: z.object({ error: z.string() })
}
}
}
});
`$3
Implement the logic. Types are enforced.`typescript
// Express Adapter Example
router.get("/posts/:id", async (req, res) => {
// req.params.id is strictly typed as string (UUID)
const post = await db.find(req.params.id);
if (!post) return res.status(404).json({ error: "Not found" });
// Return type is checked against contract
return res.json(post);
});
`$3
Consume with the generated SDK.`typescript
import { PostClient } from "./sdk/postClient";const client = new PostClient("https://api.myapp.com");
// ✨ Autocomplete heaven
const post = await client.getPost({ id: "123-abc" });
console.log(post.title);
`---
💻 CLI Commands
Your swiss-army knife for API development.
-
npx @codexsploitx/schemaapi init -> Setup project
- npx @codexsploitx/schemaapi generate resource -> Create API route
- npx @codexsploitx/schemaapi generate sdk -> Create Typed Client
- npx @codexsploitx/schemaapi generate tests -> Create Integration Tests
- npx @codexsploitx/schemaapi generate docs -> Build HTML Documentation website
- npx @codexsploitx/schemaapi audit` -> Check for security & best practices---