Giter Club home page Giter Club logo

prisma2-grpc-example's Introduction

gRPC Server Example with Prisma2

This example shows how to implement a gRPC API with TypeScript using Prisma2.

How to use

1. Clone repository & install dependencies

Clone the repository Install Node dependencies:

cd prisma2-grpc-test
npm install

2. Install the Prisma 2 CLI

To run the example, you need the Prisma 2 CLI:

npm install -g prisma2

3. Set up database

First, create a dev.db file in the prisma folder.

touch dev.db

Set up your database, run:

prisma2 lift save --name 'init'
prisma2 lift up

You can now use the SQLite Browser to view and edit your data in the ./prisma/dev.db file that was created when you ran prisma2 lift up.

4. Generate Photon (type-safe database client)

Run the following command to generate Photon JS:

prisma2 generate

Now you can seed your database using the seed script from package.json:

npm run seed

5. Start the gRPC server

npm run start

The server is now running on 0.0.0.0:50051.

6. 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 farmers.ts script sends the Farmers operation). Each script can be invoked by running the corresponding NPM script defined in package.json, e.g. npm run farmers.

prisma2-grpc-example's People

Contributors

zakayothuku avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.