Skip to content

hulk-pham/gPRC-Fullstacks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gRPC Server Example

This example shows how to implement a gRPC API with TypeScript and Prisma Client. It is based on a SQLite database, you can find the database file with some dummy data at ./prisma/dev.db.

Getting started

1. Download example and install dependencies

Download this example:

curl https://codeload.github.com/prisma/prisma-examples/tar.gz/latest | tar -xz --strip=2 prisma-examples-latest/typescript/grpc

Install npm dependencies:

cd grpc
npm install
Alternative: Clone the entire repo

Clone this repository:

git clone [email protected]:prisma/prisma-examples.git --depth=1

Install npm dependencies:

cd prisma-examples/typescript/grpc
npm install

2. Create and seed the database

Run the following command to create your SQLite database file. This also creates the User and Post tables that are defined in prisma/schema.prisma:

npx prisma migrate dev --name init

When npx prisma migrate dev is executed against a newly created database, seeding is also triggered. The seed file in prisma/seed.ts will be executed and your database will be populated with the sample data.

2. Start the gRPC server

Execute this command to start the gRPC server:

npm run dev

The server is now running on 0.0.0.0:50051.

3. Using the gRPC API

To use the gRPC API, you need a gRPC client. We provide several client scripts inside the ./client directory. Each script is named according to the operation it performs against the gRPC API (e.g. the feed.js script sends the Feed operation). Each script can be invoked by running the corresponding NPM script defined in package.json, e.g. npm run feed.

In case you prefer a GUI client, we recommend BloomRPC:

Setup to run fontend

Please refer _setup/readme.md

About

gPRC, Fullstack, React, Node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published