seamless4-service-discovery
v1.0.0
Published
Seamless Service Discovery package is for creating seamless service using typescript
Downloads
52
Maintainers
Readme
Seamless v4 Service Discovery
Seamless Service Discovery package is for creating seamless service using typescript.
Installation
npm i seamless-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 "seamless-service-discovery";
// set service options
const options: ServiceOptions = {
serRegHost: "127.0.0.1", // Service Registry Host (required)
serRegPort: 1883, // Service Registry Port (default 1883)
serRegSSL: false, // Service Registry SSL (default false)
serRegUser: "user", // Service Registry User (optional)
serRegPass: "serect", // Service Registry Pass (optional)
serAppName: "Service Name", // Service Application Name (required)
serAppPort: 3000, // Service Applicatiob Port (default 3000)
};
// 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...");
});
});