feat(server): add deployd.attach to extend http/expressjs/connect server and provide a middleware

copy functions from server.js

code cleaning and following the styles

Test: add unit test for deployd.attach