A simple state machine for Node.js