This Typescript backend uses NodeJS and Express to serve an APIs that expose pendulums states.
It simulates nodes being run on different machines with P2P synchronization.
This is why they communicate via HTTP rather than sharing state or using IPC.
In the project directory, run:
In the project directory, you can run:
Runs the app in the development mode. 5 instances of pendulums will be available at:
- http://localhost:3001
- http://localhost:3002
- http://localhost:3003
- http://localhost:3004
- http://localhost:3005
Gets the pendulum state.
Starts the simulation with the provided pendulum data.
Pauses the simulation.
Stops the simulation. The starting state is returned.
Used to report a collision. This will propagate to all pendulums in the cluster.
A restart will happen once all pendulums have acknowledged the collision.
Restart the simulation.
Only works if all pendulums have acknowledged the restart.