This example shows how to implement a gRPC API with TypeScript and Photon JS.
Clone the repository:
git clone git@github.com:prisma/photonjs.git
Install Node dependencies:
cd photonjs/examples/typescript/grpc
npm install
To run the example, you need the Prisma 2 CLI:
npm install -g prisma2
For this example, you'll use a simple SQLite database. To 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
.
Run the following command to generate Photon JS:
prisma2 generate
npm run start
The server is now running on 0.0.0.0:50051
.
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:
- Read the Prisma 2 announcement
- Check out the Prisma 2 docs
- Share your feedback in the
prisma2-preview
channel on the Prisma Slack