Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/denpalrius/grpc-node-planets
A Node.js gRPC service for managing planets using TypeScript and Protocol Buffers, including both server and client implementations.
https://github.com/denpalrius/grpc-node-planets
grpc nodejs protobuf protocol-buffers rpc typescript
Last synced: about 1 month ago
JSON representation
A Node.js gRPC service for managing planets using TypeScript and Protocol Buffers, including both server and client implementations.
- Host: GitHub
- URL: https://github.com/denpalrius/grpc-node-planets
- Owner: denpalrius
- Created: 2024-09-13T01:42:25.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T00:27:40.000Z (5 months ago)
- Last Synced: 2024-11-03T23:03:01.568Z (3 months ago)
- Topics: grpc, nodejs, protobuf, protocol-buffers, rpc, typescript
- Language: JavaScript
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gRPC Node.js Planets
This project demonstrates the use of gRPC with Node.js and TypeScript to create a simple planets service.
## Project Structure
The project consists of a gRPC server and client implementation for managing planet data.
- `src/server`: Contains the server implementation
- `src/client`: Contains the client implementation
- `proto`: Contains the Protocol Buffers definition and autogenerated schema## Installation
1. Clone the repository
2. Install dependencies:```bash
npm install
```## Usage
### Generate Protocol Buffers
Before running the server or client, generate the necessary Protocol Buffers files:
```bash
npm run proto:gen
```### Running with TypeScript
You can run the server and client directly using TypeScript:
Start the server:
```bash
npm run server
```Run the client:
```bash
npm run client
```### Running with JavaScript
To run the transpiled JavaScript version:
1. Build the project:
```bash
npm run build
```2. Start the server:
```bash
npm run server:js
```3. Run the client:
```bash
npm run client:js
```The server will start on `localhost:3000`.
The client will perform the following operations:
1. Fetch all planets
2. Get the first planet
3. Create a new random exoplanet
4. Fetch the updated list of planets## Scripts
- `npm run proto:gen`: Generate Protocol Buffers files
- `npm run clean`: Remove the dist directory
- `npm run build`: Clean and compile TypeScript
- `npm run server`: Run the TypeScript server directly
- `npm run client`: Run the TypeScript client
- `npm run server:js`: Run the compiled JavaScript server
- `npm run client:js`: Run the compiled JavaScript client## Resources
- [gRPC Documentation](https://grpc.io/docs/)
- [Protocol Buffers Documentation](https://developers.google.com/protocol-buffers/docs/overview)
- [Node.js gRPC Tutorial](https://grpc.io/docs/languages/node/quickstart/)
- [Implementing a gRPC client and server in Typescript with Node (Youtube)](https://www.youtube.com/watch?v=H0c4Wjl4kRQ&ab_channel=JustinBrooks)