Skip to content

Instantly share code, notes, and snippets.

@heisian
Created November 4, 2019 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heisian/8d64e8c25bd64f04c1206bec0e069e88 to your computer and use it in GitHub Desktop.
Save heisian/8d64e8c25bd64f04c1206bec0e069e88 to your computer and use it in GitHub Desktop.
exercise

Fullstack Exercise (Tim)

Create a Node server/client app that communicates via socket.io.

Server/Client interaction

Connection

The server should listen for socket.io connections and let any clients know, on connection, that they've successfully connected. The server should emit a success message to the client through the socket.io channel.

The client, once connected to the server's socket.io channel, should receive that message and output it within the HTML body.

Data Transfer

The server should also accept requests (through the socket.io channel) to emit its environment variables (process.env) to the client.

On the client, a user should be able to click a form button that sends the request to the server for its environment variables, and the server should respond as such.

Since we are communicating over an insecure connection, the process.env should be stringified and encrypted with a strong cipher and passphrase. You should use Node's built in crypto module.

Requirements

  • The exercise must be completed within an hour. You may use the web as a resource.
  • You may only use one dependency: socket.io.
    • You will only need two methods: socket.on and socket.emit.
  • Your server must serve the client page on port 9999.
  • Your server must listen for socket.io connections on 9998.
  • The server should alert the client of a successful connection.
  • The server should respond to the client's request for its process.env object.
  • The server should encrypt process.env before sending it to the client.
    • Use an 'AES-128' encryption algorithm or higher.
    • You do not need to use/sign an encryption key, a simple passphrase is sufficient.
  • The client page should follow valid HTML and Javascript syntax.
  • The client page should not include any external libraries other than socket.io.

Your code will be evaluated on cleanliness and functionality. If you have not used socket.io before, you may take a few minutes to view their "Get Started" page: https://socket.io/get-started/chat/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment