Create main.js

split the code into client and server, this is the server commit.