Nightscout simulator

This pretends to be a Nightscout instance with a Loop app behind it. It exists so CarbSnap's development environment can exercise the entire command path — headers, one-time password, payload shape, response handling — without anything reaching a real insulin pump.

No pump. No person. Nothing here affects anyone. Production is configured never to send commands here, so a simulated Loop cannot stand in for a real one.

Failure modes can be forced with ?fail=:

The phone can also be stopped directly, which is the one state a simulator whose data is a function of the clock can never reach: POST /sim/quiet freezes glucose and device status at this moment, so both age in real time while Nightscout keeps answering with them. POST /sim/quiet?at=<ms> puts the silence in the past, and POST /sim/reset brings the phone back.

Push delivery can be delayed the same way, which is the failure the test suite could not see: POST /sim/late?mode=all makes every push arrive 90 s late, so its one-time password has expired by the time the phone reads it; ?mode=once delays only the next one, which is what a re-send recovers from; ?mode=off stops it. /sim/reset clears the mode along with everything else, so set it after seeding a world rather than before — set first, it looks like it worked and the push arrives on time.