@type_sync/typesync
v0.1.2
Published
Type-safe fullstack framework with automatic validation - batteries included
Maintainers
Readme
TypeSync
Type-safe fullstack framework with automatic validation - batteries included
One package, everything you need for production-ready type-safe APIs.
Installation
npm install @type_sync/typesync zodQuick Start
Backend
import { createRouter } from '@type_sync/typesync';
import { applyRoutes } from '@type_sync/typesync/express';
import { z } from 'zod';
import express from 'express';
const userRouter = createRouter('/users');
userRouter.post('/', {
body: z.object({
name: z.string(),
email: z.string().email()
}),
response: z.object({
id: z.string(),
name: z.string()
})
}, async ({ body }) => {
return { id: '1', name: body.name };
});
const app = express();
app.use(express.json());
applyRoutes(app, userRouter);
app.listen(3000);Frontend
import { createTypeSyncHooks } from '@type_sync/typesync/react';
const { usePost } = createTypeSyncHooks('/users');
function CreateUser() {
const create = usePost();
return <button onClick={() => create.mutate({
body: { name: 'Alice', email: '[email protected]' }
})}>Create</button>;
}Available Exports
@type_sync/typesync- Core + Client@type_sync/typesync/react- React hooks@type_sync/typesync/vue- Vue composables@type_sync/typesync/express- Express adapter@type_sync/typesync/fastify- Fastify adapter@type_sync/typesync/nestjs- NestJS adapter@type_sync/typesync/graphql- GraphQL adapter@type_sync/typesync/database- Database ORM@type_sync/typesync/redis- Redis cache@type_sync/typesync/email- Email service@type_sync/typesync/tracing- Distributed tracing@type_sync/typesync/auth- Authentication@type_sync/typesync/lambda- AWS Lambda@type_sync/typesync/monitoring- Monitoring@type_sync/typesync/queue- Job queue@type_sync/typesync/websocket- WebSocket@type_sync/typesync/sse- Server-Sent Events@type_sync/typesync/cli- CLI tools@type_sync/typesync/openapi- OpenAPI generator@type_sync/typesync/testing- Testing utilities
Documentation
License
MIT
