Dapr-JS SDK Overview

Dapr is a portable, serverless, event-driven runtime that makes it easy for developers to build resilient, stateless and stateful microservices that run on the cloud and edge and embraces the diversity of languages and developer frameworks.

Dapr codifies the best practices for building microservice applications into open, independent, building blocks that enable you to build portable applications with the language and framework of your choice. Each building block is independent and you can use one, some, or all of them in your application.

Here is a link for creating a Dapr project with Node.JS and the Dapr-JS SDK: lnkd.in/dJEHmsaH

Image description

Dapr-JS SDK Docs

import { DaprClient, DaprServer, HttpMethod, CommunicationProtocolEnum } from "dapr-client";

const daprHost = "127.0.0.1"; // Dapr Sidecar Host
const daprPort = "3500"; // Dapr Sidecar Port of this Example Server
const serverHost = "127.0.0.1"; // App Host of this Example Server
const serverPort = "50051"; // App Port of this Example Server 

// HTTP
const server = new DaprServer(
     serverHost, serverPort, 
     daprHost, daprPort
); 

const client = new DaprClient(daprHost, daprPort);

// GRPC 
const server = new DaprServer(
    serverHost, serverPort, 
    daprHost, daprPort, 
    CommunicationProtocolEnum.GRPC
 );

const client = new DaprClient(
     daprHost, daprPort, 
     CommunicationProtocolEnum.GRPC
 );