Session 3 : Websockets#5
Open
guillaumeduboc wants to merge 4 commits into
Open
Conversation
| @@ -14,18 +15,49 @@ export const createConnection = async ( | |||
| endpoint: string, | |||
| ): Promise<void> => { | |||
| // TODO insert a connection in the DynamoDB | |||
Collaborator
There was a problem hiding this comment.
Tu peux enlever ça du coup
| // TODO insert a connection in the DynamoDB | ||
| await documentClient | ||
| .put({ | ||
| TableName: 'dojo-serverless-table', |
Collaborator
There was a problem hiding this comment.
Tu peux mettre ça dans une constante
| }; | ||
|
|
||
| export const deleteConnection = async (connectionId: string): Promise<void> => { | ||
| // TODO delete a connection from the DynamoDB |
| @@ -7,11 +7,38 @@ import { Item } from '@libs/types'; | |||
| import { Virus } from '../virus/types'; | |||
|
|
|||
| const sendMessageToEachConnection = async (message: any): Promise<void> => { | |||
Collaborator
There was a problem hiding this comment.
Pas une bonne pratique de typer en any
Comment on lines
9
to
17
| const sendMessageToEachConnection = async (message: any): Promise<void> => { | ||
| // TODO use sendMessageToConnection for each connection | ||
| // TODO use sendMessageToConnection for each connection | ||
| const connections = await getAllConnections(); | ||
| await Promise.all( | ||
| connections.map(async ({ connectionId, endpoint }): Promise<void> => { | ||
| await sendMessageToConnection({ connectionId, endpoint, message }); | ||
| }), | ||
| ); | ||
| }; |
Collaborator
There was a problem hiding this comment.
Tu peux sortir ça du handler du coup :)
Comment on lines
75
to
82
| const addVirus = async () => { | ||
| const response = await fetch( | ||
| `${process.env.REACT_APP_API_BASE_URL}/virus`, | ||
| { method: 'POST' }, | ||
| ); | ||
| const { id } = await response.json(); | ||
| setViruses((prevViruses) => prevViruses.concat(getRandomVirus(id))); | ||
| // const response = | ||
| await fetch(`${process.env.REACT_APP_API_BASE_URL}/virus`, { | ||
| method: 'POST', | ||
| }); | ||
| // const { id } = await response.json(); | ||
| // setViruses((prevViruses) => prevViruses.concat(getRandomVirus(id))); | ||
| }; |
Collaborator
There was a problem hiding this comment.
Tu peux faire du ménage ici ;)
| // setViruses((prevViruses) => prevViruses.concat(getRandomVirus(id))); | ||
| }; | ||
|
|
||
| const killVirus = async (virusId: string) => { |
Collaborator
There was a problem hiding this comment.
Je pense que tu peux sortir ces fonctions de ta page (et je t'ai déjà fait le retour ;) )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tu peux ignorer les changement liés aux alarmes, j'ai oublié de checkout sur une autre branche pour le faire