seamless4-service-discovery
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

Seamless v4 Service Discovery

Seamless Service Discovery NPM package using NodeJS.

Installation

npm i seamless4-service-discovery

Importing the module in your application

Add the below code snippet in your Typescript application

// import seamless service discovery
import { Service, SrvRequest, SrvResponse } from "seamless4-service-discovery";

// get service instance
const service = Service({
  srvRegHost: "127.0.0.1", // Service Registry Host (required)
  srvRegPort: 1883, // Service Registry Port (default 1883)
  srvRegSSL: false, // Service Registry SSL (default false)
  srvRegUser: "user", // Service Registry User (optional)
  srvRegPass: "serect", // Service Registry Pass (optional)
  srvAppName: "Service Name", // Service Application Name (required)
  srvAppId: "unique-app-id", // Service Application ID (required)
  srvAppUrl: "http://127.0.0.1:3000", // Service Application URL (optional)
  srvAppAuthor: "Author Name", // Service Application Author (optional)
  srvAppMeta: [
    // Service Application Meta Information (optional)
    {
      path: "/",
      method: "GET",
      protocol: "http",
      description: "This is a default route of this service application",
    }
  ]
});

// define rest endpoint
service.app.get("/", async (req: SrvRequest, res: SrvResponse) => {
  res.send("response from service router...");
});

// define rest endpoint
service.app.get("/other", async (req: SrvRequest, res: SrvResponse) => {
  res.send("response from service router other...");
});

// run service
service.run();

Add the below code snippet in your Javascript application

// import seamless service discovery
const { Service } = require("seamless4-service-discovery");

// get service instance
const service = Service({
  srvRegHost: "127.0.0.1", // Service Registry Host (required)
  srvRegPort: 1883, // Service Registry Port (default 1883)
  srvRegSSL: false, // Service Registry SSL (default false)
  srvRegUser: "user", // Service Registry User (optional)
  srvRegPass: "serect", // Service Registry Pass (optional)
  srvAppName: "Service Name", // Service Application Name (required)
  srvAppId: "unique-app-id", // Service Application ID (required)
  srvAppUrl: "http://127.0.0.1:3000", // Service Application URL (optional)
  srvAppAuthor: "Author Name", // Service Application Author (optional)
  srvAppMeta: [
    // Service Application Meta Information (optional)
    {
      path: "/",
      method: "GET",
      protocol: "http",
      description: "This is a default route of this service application",
    }
  ]
});

// define rest endpoint
service.app.get("/", async (req, res) => {
  res.send("response from service router...");
});

// define rest endpoint
service.app.get("/other", async (req, res) => {
  res.send("response from service router other...");
});

// run service
service.run();

Package Sidebar

Install

npm i seamless4-service-discovery

Weekly Downloads

3

Version

1.0.8

License

ISC

Unpacked Size

53.9 kB

Total Files

9

Last publish

Collaborators

  • somnetics