Skip to content

Session 1 : Adding getVirus, createVirus and deleteVirus#1

Open
guillaumeduboc wants to merge 4 commits into
session-1-v3from
session-1-v3-getVirus
Open

Session 1 : Adding getVirus, createVirus and deleteVirus#1
guillaumeduboc wants to merge 4 commits into
session-1-v3from
session-1-v3-getVirus

Conversation

@guillaumeduboc

Copy link
Copy Markdown
Owner

No description provided.

@guillaumeduboc guillaumeduboc changed the title Adding a getVirus route Session 1 : Adding getVirus, createVirus and deleteVirus Oct 20, 2021
Comment thread backend/functions/getVirus.ts Outdated

const listOfViruses: Array<Virus> = [{id: 1, type: 1},{id: 2, type: 1},{id: 3, type: 3},{id: 4, type: 2},{id: 5, type: 1}]

export const main: APIGatewayProxyHandler = async event => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux déstructurer ton objet event pour plus de lisibilité :
export const main: APIGatewayProxyHandler = async { queryStringParameters } => {

Comment thread backend/functions/getVirus.ts Outdated
const listOfViruses: Array<Virus> = [{id: 1, type: 1},{id: 2, type: 1},{id: 3, type: 3},{id: 4, type: 2},{id: 5, type: 1}]

export const main: APIGatewayProxyHandler = async event => {
if (event.queryStringParameters != null && Object.keys(event.queryStringParameters).includes("id")){

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Du coup tu peux faire const {id} = queryStringParameters puis if (id !== null)

Comment thread backend/functions/getVirus.ts Outdated
Comment on lines +10 to +17
return {
statusCode: 200,
body: JSON.stringify({
message: targettedVirus,
input: event,
}),
};
} else {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux éviter la duplication en écrivant un générateur de réponse HTTP

Comment thread backend/functions/deleteVirus.ts Outdated
Comment on lines +7 to +9
headers: {
'Access-Control-Allow-Origin': '*',
},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread backend/types/virus.ts Outdated
id: string;
positionX: number;
positionY: number;
virus_category: number;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prends l'habitude d'utiliser du camelCase : https://fr.wikipedia.org/wiki/Camel_case

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants