Skip to content

veloxts/velox-ts-framework

Repository files navigation

Velox TS Framework

Early Access (v0.8.x)

Velox TS (pronounced Velox TypeScript) is a full-stack TypeScript framework with end-to-end type safety—no code generation required. Convention-driven APIs that generate both tRPC and REST from a single source.

Key Features

  • Type Safety Without Code Generation – Types flow naturally from backend to frontend through direct imports. No build step required for type synchronization.

  • Unified API Layer - Define your API once with procedures, get both tRPC (for internal type-safe calls) and REST endpoints (for external consumers) automatically.

  • Full REST Support - Convention-based routing for all HTTP methods:

    • getUser / findUserGET /api/users/:id
    • listUsersGET /api/users
    • createUser / addUserPOST /api/users
    • updateUser / editUserPUT /api/users/:id
    • patchUserPATCH /api/users/:id
    • deleteUser / removeUserDELETE /api/users/:id
  • Built-in Authentication - JWT and session-based auth with guards, rate limiting, CSRF protection, and token rotation.

  • Complete Ecosystem - Production-ready packages for caching, queues, email, storage, scheduling, and real-time events.

  • Modern Stack - Built on proven technologies: Fastify, tRPC, Prisma, and Zod.

  • Elegant, Expressive Syntax - Fluent builder APIs with full IntelliSense support and minimal boilerplate.

Documentation

veloxts.dev/docs - Full documentation including getting started guides, API reference, deployment, and more.

Quick Start

# Create a new project (default template)
npx create-velox-app my-app

# Or with authentication included
npx create-velox-app my-app --auth

# Navigate to project
cd my-app

# Set up database
npm run db:push

# Start development server
npm run dev

Your API is now running at http://localhost:3030.

Available Templates

Template Command Description
Default npx create-velox-app my-app Basic REST API with user CRUD procedures
Auth npx create-velox-app my-app --auth Full authentication (JWT, sessions, guards)
tRPC npx create-velox-app my-app --trpc tRPC-only setup for type-safe internal APIs
RSC npx create-velox-app my-app --rsc Full-stack React Server Components with Vinxi
RSC + Auth npx create-velox-app my-app --rsc-auth RSC with JWT authentication and server actions

Example: Defining Procedures

import { procedure, procedures, z } from '@veloxts/velox';

export const userProcedures = procedures('users', {
  // GET /api/users/:id
  getUser: procedure()
    .input(z.object({ id: z.string().uuid() }))
    .query(async ({ input, ctx }) => {
      return ctx.db.user.findUniqueOrThrow({ where: { id: input.id } });
    }),

  // GET /api/users
  listUsers: procedure()
    .query(async ({ ctx }) => {
      return ctx.db.user.findMany();
    }),

  // POST /api/users
  createUser: procedure()
    .input(z.object({
      name: z.string().min(1),
      email: z.string().email(),
    }))
    .mutation(async ({ input, ctx }) => {
      return ctx.db.user.create({ data: input });
    }),
});

Ecosystem Features

VeloxTS includes a complete set of infrastructure packages for common application needs:

// Multi-driver caching with tag-based invalidation
await ctx.cache.remember('user:123', '30m', () => fetchUser());
await ctx.cache.tags(['users']).flush();

// Background job processing
await dispatch(SendWelcomeEmail, { userId: '123', email: 'user@example.com' });

// Email with React templates
await send({
  to: 'user@example.com',
  subject: 'Welcome!',
  react: <WelcomeEmail name="John" />,
});

// File storage abstraction
await ctx.storage.put('avatars/user-123.jpg', buffer);
const url = await ctx.storage.url('avatars/user-123.jpg');

// Fluent cron scheduling
schedule('cleanup-sessions').call(cleanupExpiredSessions).daily().at('03:00');

// Real-time broadcasting
broadcast('orders', { event: 'order.created', data: { orderId: '123' } });

Packages

Core Packages

Package Description
@veloxts/velox Umbrella package - all framework features in one import
@veloxts/core Fastify wrapper, plugin system, error handling, and application lifecycle
@veloxts/router Procedure definitions with tRPC and REST routing
@veloxts/validation Zod integration and common validation schemas
@veloxts/orm Prisma wrapper with enhanced developer experience
@veloxts/auth JWT, sessions, guards, rate limiting, CSRF protection
@veloxts/client Type-safe frontend API client
@veloxts/cli Development server with HMR and CLI commands
@veloxts/web React Server Components with Vinxi, file-based routing, server actions
@veloxts/mcp Model Context Protocol server for AI tool integration
create-velox-app Interactive project scaffolder

Ecosystem Packages

Package Description
@veloxts/cache Multi-driver caching (memory, Redis) with tag-based invalidation
@veloxts/queue Background job processing with sync and BullMQ drivers
@veloxts/mail Email sending with SMTP, Resend, and React Email template support
@veloxts/storage File storage abstraction for local filesystem and S3/R2
@veloxts/scheduler Fluent cron task scheduling with overlap protection
@veloxts/events Real-time broadcasting via WebSocket and SSE with Redis pub/sub

Requirements

  • Node.js 20 or later
  • TypeScript 5 or later
  • pnpm, npm, or yarn

Development

This is a monorepo managed with pnpm and Turborepo.

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests
pnpm test

# Type check
pnpm type-check

# Lint
pnpm lint

Current Status

v0.8.x - Pre-release with stable core features.

The framework provides a solid foundation for building type-safe APIs:

Feature Status
Core framework ✅ Stable
Procedure-based routing ✅ All HTTP methods (GET, POST, PUT, PATCH, DELETE)
Prisma integration ✅ Stable
Type-safe client ✅ Stable
JWT Authentication ✅ Available
Session Authentication ✅ Available
Guards & Authorization ✅ Available
Rate Limiting ✅ Available
Development CLI with HMR ✅ Available
Project scaffolder ✅ Available (default, auth, trpc, rsc, rsc-auth templates)
MCP Server (AI integration) ✅ Available
CLI code generators ✅ 16 generators available
Database seeding ✅ Seeder generator available
OpenAPI generation ✅ CLI + Fastify Swagger plugin
velox sync ✅ Prisma-to-procedure sync with 5-stage pipeline
Resource API resourceSchema() with tagged views and auto-projection
Auth adapters ✅ BetterAuth, Clerk, Auth0
Ecosystem Packages
Multi-driver caching ✅ Available (memory, Redis)
Background job processing ✅ Available (sync, BullMQ)
Email sending ✅ Available (SMTP, Resend, React Email)
File storage ✅ Available (local, S3/R2)
Cron task scheduling ✅ Available
Real-time broadcasting ✅ Available (WebSocket, SSE)

What Works Well

  • Fluent procedure builder API with excellent type inference
  • Convention-based REST route generation for all HTTP methods
  • End-to-end type safety without code generation
  • Resource API with tagged schema views for context-dependent outputs
  • OpenAPI 3.0.3 generation with CLI and Swagger UI plugin
  • Comprehensive authentication system (JWT + sessions + pluggable adapters)
  • Guard-based authorization with composable rules
  • velox sync for Prisma-to-procedure synchronization
  • Hot Module Replacement in development
  • 16 code generators (velox make <type>) for rapid development
  • AI-native development with MCP server integration
  • React Server Components with Vinxi and file-based routing
  • Complete ecosystem packages (cache, queue, mail, storage, scheduler, events)

Current Limitations

  • Small ecosystem (early adopter stage)
  • Flight protocol (RSC streaming) not yet implemented

Contributing

This project is in pre-alpha development. We welcome feedback and bug reports through GitHub issues.

For code contributions, please open an issue first to discuss the proposed changes. The API is stabilizing but may still evolve before v1.0.

License

MIT