code from the Building Node Apps book