#14. Mock server
Now let's move from "calling a service" to "integrating with a service."
#Start the live demo server
telepact demo-server --port 8000#Start a mock server from the live schema
In a second terminal:
telepact mock --http-url http://localhost:8000/api --port 8001 --path /apiThe mock server absorbs the live server's schema, which makes it a great integration partner while we are building a client.
#The normal integration pattern
This should be our default habit:
point a mock at the live Telepact server
develop against the mock first
switch to the live service later
If we want a cached local copy of the schema, we can also do this:
telepact fetch --http-url http://localhost:8000/api --output-dir ./cached-schema
telepact mock --dir ./cached-schema --port 8001 --path /api#Compare the public schema
Live server:
curl -s localhost:8000/api -d '[{}, {"fn.api_": {}}]'Mock server:
curl -s localhost:8001/api -d '[{}, {"fn.api_": {}}]'Those public schemas match.
If we include internal definitions on the mock, we see more:
curl -s localhost:8001/api -d '[{}, {"fn.api_": {"includeInternal!": true}}]'That extra surface is the mock's control plane.
Next: 15. Stock mock