seamless4-service-discovery
v1.0.3
Published
Seamless Service Discovery package is for creating seamless service using typescript
Downloads
244
Maintainers
Readme
Seamless v4 Service Discovery
Seamless Service Discovery package is for creating seamless service using typescript.
Installation
npm i seamless4-service-discovery
Importing the module in your application
Add the below code snippet in your app.ts file
// import seamless service discovery
import Service, {
ServiceOptions,
SrvRouter,
SrvRequest,
SrvResponse,
} from "seamless4-service-discovery";
// set service options
const options: ServiceOptions = {
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)
srvAppUrl: "http://127.0.0.1:3000" // Service Application URL (optional)
};
// define service router
Service(options, (router: SrvRouter) => {
// define rest endpoint
router.get("/", async (req: SrvRequest, res: SrvResponse) => {
res.send("response from service router...");
});
// define rest endpoint
router.get("/other", async (req: SrvRequest, res: SrvResponse) => {
res.send("response from service router other...");
});
});