To initiate an asynchronous simulation replay job, external clients must format a strict JSON payload and dispatch it to the Fastify server via an HTTP POST request. This initial request is the critical handshake between the client and the distributed execution architecture. If the request lacks proper MIME type headers, the Fastify server will instantly reject the payload with an HTTP 415 Unsupported Media Type error. If the network request fails due to DNS resolution issues or server downtime, an unhandled Promise rejection will immediately crash the client process, destroying the session.
Issues/what to fix
The script requires a resilient HTTP client wrapper built around the native Node.js fetch API. This wrapper must explicitly set the Content Type: application/json and Accept: application/json headers to satisfy the Fastify server's strict payload validation schema. The wrapper must stringify the tx_hash payload and execute the POST request to the local http://localhost:3001/api/replay endpoint. Following the network call, the script must programmatically evaluate the HTTP Response.ok boolean property to verify that a successful 200 OK or 201 Created status code was returned. It must then safely execute Response.json() to deserialize the server's reply and extract the unique jobId token, throwing a descriptive exception if the server returns a 500 Internal Server Error.
Files location
examples/api clients/mock replay submitter/index.js
Expected result
The script will successfully negotiate the initial HTTP handshake with the Fastify REST API, safely encode and dispatch the transaction hash payload, gracefully handle network level connection refused errors, and secure the unique jobId required for tracking the simulation progress.
Contributor telegram group
https://t.me/+sII7WPhll2liMGNk
To initiate an asynchronous simulation replay job, external clients must format a strict JSON payload and dispatch it to the Fastify server via an HTTP POST request. This initial request is the critical handshake between the client and the distributed execution architecture. If the request lacks proper MIME type headers, the Fastify server will instantly reject the payload with an HTTP 415 Unsupported Media Type error. If the network request fails due to DNS resolution issues or server downtime, an unhandled Promise rejection will immediately crash the client process, destroying the session.
Issues/what to fix
The script requires a resilient HTTP client wrapper built around the native Node.js fetch API. This wrapper must explicitly set the Content Type: application/json and Accept: application/json headers to satisfy the Fastify server's strict payload validation schema. The wrapper must stringify the tx_hash payload and execute the POST request to the local http://localhost:3001/api/replay endpoint. Following the network call, the script must programmatically evaluate the HTTP Response.ok boolean property to verify that a successful 200 OK or 201 Created status code was returned. It must then safely execute Response.json() to deserialize the server's reply and extract the unique jobId token, throwing a descriptive exception if the server returns a 500 Internal Server Error.
Files location
examples/api clients/mock replay submitter/index.js
Expected result
The script will successfully negotiate the initial HTTP handshake with the Fastify REST API, safely encode and dispatch the transaction hash payload, gracefully handle network level connection refused errors, and secure the unique jobId required for tracking the simulation progress.
Contributor telegram group
https://t.me/+sII7WPhll2liMGNk