/js-sdk

Dapr SDK for Javascript

Primary LanguageJavaScriptMIT LicenseMIT

Dapr SDK for Javascript

This is the Dapr SDK for Javascript, based on the auto-generated proto client.

For more info on Dapr and gRPC, visit this link.

This repo generates following package: dapr.io

Usage

Dapr javascript sdk package can be installed as:

npm install dapr-client

Creating the client

var dapr = require('dapr-client');
var messages = dapr.dapr_pb; 
var services = dapr.dapr_grpc;
var grpc = require('grpc');

const PORT = process.env.DAPR_GRPC_PORT || 50001;
var client = new services.DaprClient(`localhost:${PORT}`, grpc.credentials.createInsecure());

For usage, refer to examples/simple/app.js

Running the code locally.

From the root directory:

cd src
npm install

From the root directory:

cd examples/simple
npm install
dapr run --app-protocol grpc --dapr-grpc-port=50001 node app.js

Generate gRPC interface and proto buf stubs

  1. Make the protobuf.sh executable
sudo chmod +x protobuf.sh
  1. Run the protobuf.sh script
./protobuf.sh

Use the package from local source

From the root directory:

cd examples/simple
npm install ../..

Creating and publishing the package

  1. Update the version in package.json

  2. From the root directory:

npm pack
npm publish --access public

Note --access public will publish the package publicly. For all publish options see https://docs.npmjs.com/cli/publish