An open API service indexing awesome lists of open source software.

https://github.com/thednp/vite-uni-rpc

⚡ A Vite plugin for creating server functions with automatic Remote Procedure Calls (RPC) generation
https://github.com/thednp/vite-uni-rpc

express fastify fastify-plugin hono rpc-library vite

Last synced: 2 months ago
JSON representation

⚡ A Vite plugin for creating server functions with automatic Remote Procedure Calls (RPC) generation

Awesome Lists containing this project

README

          

## vite-uni-rpc

A Vite plugin for creating server functions with automatic Remote Procedure Calls generation.

### Features

- File-level server code isolation without using directives like `'use server'`
- System wide configuration via vite like config file
- Automatic RPC generation for server functions
- Server-side caching with single-flight requests
- Flexible middleware system with hooks support and adapters for `express`, `fastify` and `hono`
- Framework agnostic
- TypeScript support

> NOTE - this is a work in progress plugin. Do not use in production apps.

### Examples

| Example | Source Code | Try online |
| ------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| SPA - node:http | [SPA](https://github.com/thednp/vite-uni-rpc/tree/main/examples/spa) | [StackBlitz](https://stackblitz.com/fork/github/thednp/vite-uni-rpc/tree/main/examples/spa) |
| Express | [Express](https://github.com/thednp/vite-uni-rpc/tree/main/examples/express) | [StackBlitz](https://stackblitz.com/fork/github/thednp/vite-uni-rpc/tree/main/examples/express) |
| Fastify | [Fastify](https://github.com/thednp/vite-uni-rpc/tree/main/examples/fastify) | [StackBlitz](https://stackblitz.com/fork/github/thednp/vite-uni-rpc/tree/main/examples/fastify) |
| Hono | [Hono](https://github.com/thednp/vite-uni-rpc/tree/main/examples/hono) | [StackBlitz](https://stackblitz.com/fork/github/thednp/vite-uni-rpc/tree/main/examples/hono) |

### Installation

```bash
npm install vite-uni-rpc@latest
```

```bash
pnpm add vite-uni-rpc@latest
```

### Wiki

Please refer to the [Wiki](https://github.com/thednp/vite-uni-rpc/wiki) for guides on installation, configuration and usage.

### TO DO

- [ ] Add/update examples examples
- [ ] Add AbortController
- [ ] Fix `The plugin "vite:dep-scan" was triggered by this import server/server.mjs:1:29: 1 │ import { createServer } from "vite";`
- [x] Add SPA support
- [x] Add wiki
- [x] Test bun
- [x] Add `contentType` option to `createServerFunction`, currently supporting: `application/json`, `text/plain`;
- [ ] Add koa adapter
- [ ] Add Github tooling/workflows
- [ ] Add tests

### To know
* in dev mode **only** vite dev server and express/connect middleware are available

### Credits

This project is inspired by [vite-dev-rpc](https://github.com/antfu/vite-dev-rpc).

### License
Released under [MIT](LICENSE).