undefined if the given service has no port in its service origin.
import {findDevServicePort, defineService, AnyOrigin} from '@rest-vir/define-service';
const myService = defineService({
serviceName: 'my-service',
serviceOrigin: 'https://localhost:3000',
requiredClientOrigin: AnyOrigin,
endpoints: {
'/my-path': {
methods: {
[HttpMethod.Get]: true,
},
requestDataShape: undefined,
responseDataShape: undefined,
},
},
});
const {origin} = await findDevServicePort(myService);
Use this to find a service's port number when started without a locked-in port. This allows a client (usually a website frontend) to find which port the server started on by scanning ports starting with the port defined in the service's
serviceOriginproperty.If the service has no port in its
serviceOriginproperty, this function throws an error.Note that the service given must have at least one endpoint defined for this function to work.
This is used in
defineServiceif thefindActiveDevPortoption is set to true.