https://github.com/funduck/nestjs-connectrpc-fastify
Example integration of ConnectRPC over HTTP/1 into Nestjs framework
https://github.com/funduck/nestjs-connectrpc-fastify
connectrpc fastify nest nestjs nodejs
Last synced: 5 months ago
JSON representation
Example integration of ConnectRPC over HTTP/1 into Nestjs framework
- Host: GitHub
- URL: https://github.com/funduck/nestjs-connectrpc-fastify
- Owner: funduck
- Created: 2026-01-04T19:38:44.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-01-19T18:29:28.000Z (5 months ago)
- Last Synced: 2026-01-19T19:51:42.119Z (5 months ago)
- Topics: connectrpc, fastify, nest, nestjs, nodejs
- Language: TypeScript
- Homepage:
- Size: 4.19 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Description
This is an example of production integration of [ConnectRPC](https://github.com/connectrpc/connect-es) for Nodejs into
[Nest](https://github.com/nestjs/nest) framework.
### Basic example
Configure `ConnectRPCModule` in some of your modules, usually `app.module.ts` is used for such things:
```TS
@Module({
imports: [
ConnectRPCModule.forRoot({
logger: new Logger('ConnectRPC', { timestamp: true }),
}),
]
})
export class AppModule {}
```
At least one controller should implement service described in proto
```TS
export class ConnectrpcController implements Service {
constructor() {
ConnectRPC.registerController(this, ElizaService);
}
async say(
request: SayRequest,
) {
return {
sentence: `You said: ${request.sentence}`,
};
}
```
And during bootstrap register plugin **after** `app` is created and **before** it is initialized
```TS
const app = await NestFactory.create(
AppModule,
new FastifyAdapter(),
);
await app.get(ConnectRPCModule).registerPlugin();
await app.listen(80);
```
For more details start reading from `src/app.module.ts`
### Features
This example shows:
* rpc with simple request and response messages
* rpc with stream in response
* rpc with stream in request
* how to use middlewares
* how to use global guards
*RPC with bidirectional stream is out of current scope because it requires HTTP/2 which is unstable in public networks. Practice demostrates more consistent performance over HTTP/1.*
## Prerequisites
* Nodejs
* Nest + Fastify server
## Project setup
```bash
$ pnpm install
```
To compile proto files if you change them
```bash
$ pnpm run compile-proto
```
## Compile and run the test
```bash
$ pnpm run test
```
## Test output




## Feedback
Please use [Discussions](https://github.com/funduck/nestjs-connectrpc-fastify/discussions) or email me.
