amazon-chime-sdk-js icon indicating copy to clipboard operation
amazon-chime-sdk-js copied to clipboard

Suggestion: refine implementation of the local demo server

Open PeterAronZentai opened this issue 4 years ago • 0 comments

I think it is not really a huge issue, but the current local demo implementations could be refined on several ways. This ticket is about the server side of the local browser demo (https://github.com/aws/amazon-chime-sdk-js/blob/master/demos/browser/server.js)

Suggested Change 1)

Do use express and proper route based handlers for the server side - instead of just using http and a single response handler with 5 if and elseif branches. I understand using http is one less opinion/library in, but virtually nobody is using just http in nodejs land - some form of a http service library is always used - mainly because of route based handlers are easier to read through, reason about, etc.

Suggested Change 2)

Instead of using a memory array to store and resolve meetings by name - use tags. More details in this comment: https://github.com/aws/amazon-chime-sdk-js/issues/109#issuecomment-674554899

Suggested Change 3)

Remove everything that is not necessary for the demo to work. For example, compression is being enabled in the demo http server. I might be wrong, but by the looks of it compression isnt at all needed for those small json responses, it just confuses the reader if the server side will need to participate in some more work? Also compression is better enabled in another tier, like CloudFront - using nodejs to compress data isnt scaling very well.

Suggested Change 4)

Use destructuring in the starter section of the method, to spare mulitple dot notation references and create easy to read local const variables of the key fields. request.method is used 6 times, requestUrl.query is used 11 times, and so on.

I'd be happy to do these changes if you guys think my points are valid.

PeterAronZentai avatar Aug 16 '20 17:08 PeterAronZentai