Skip to content

cnpap/vtzac

Repository files navigation

vtzac

Vite + NestJS Full-Stack Development Tool - Type-safe, zero-boilerplate frontend-backend communication

npm version license

English | 中文

vtzac is a full-stack development tool for Vite + NestJS that enables frontend to directly call backend controllers (HTTP & WebSocket) in a "type-safe, zero-boilerplate" manner, while providing clean abstractions for server-side event emission.

🚀 Quick Start

1. Installation

pnpm add vtzac

2. Configure Vite Plugin

import { defineConfig } from 'vite';
import vtzac from 'vtzac';

export default defineConfig({
  plugins: [vtzac()],
});

3. Start Using

Frontend can directly reference backend project to achieve type-safe calls.

📖 Feature Demonstrations

HTTP Calls

import { _http } from 'vtzac';
import { AppController } from 'backend/src/app.controller';

const api = _http({
  ofetchOptions: { baseURL: 'http://localhost:3000' },
}).controller(AppController);

// Type-safe method calls
const res = await api.getHello();
console.log(res._data); // Output: 'Hello World!'

WebSocket Communication

import { _socket } from 'vtzac';
import { WebSocketGateway } from 'backend/src/websocket.gateway';

const { emitter, createListener } = _socket(
  'http://localhost:3000',
  WebSocketGateway
);

// Send messages
emitter.handleMessage({ text: 'Hello!' });

// Listen to events
const listener = createListener(EventEmitter);
listener.message(data => console.log(data));

📚 Documentation

📦 Installation

pnpm add vtzac

🤝 Contributing

Issues and Pull Requests are welcome!

📄 License

MIT © cnpap

About

Vite + NestJS's new era full stack solution

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 6