Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#15 Feature/15 create gungi game #25

Merged
merged 5 commits into from
Nov 14, 2023
Merged

Conversation

zhihdd
Copy link
Collaborator

@zhihdd zhihdd commented Oct 4, 2023

#15

Description

send request to initialilze gungi game

How to test

// api route
{POST} /gungi/create

// request
{ 
   players: { id: string; nickname: string }[] 
}

// response 
status: 200
{
  url: string 
}

New Dependencies

allenh
allenh previously requested changes Oct 16, 2023
Copy link
Contributor

@allenh allenh left a comment

Choose a reason for hiding this comment

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

General Comments

  • add an e2e test for validating user input (ie. body should contain a list of players and it should be 2, otherwise return 400)
  • think of other places where you need to be more defensive of inputs and where things will break

At the minimum it needs to defend against these cases:

  • 1 - no body
curl --location --request POST 'localhost:8000/gungi/create' \
--header 'Content-Type: application/json' \
--data-raw '{}'
  • 2 - wrong body
curl --location --request POST 'localhost:8000/gungi/create' \
--header 'Content-Type: application/json' \
--data-raw '{
    "somethingElse": []
}'
  • 3 - wrong player data
curl --location --request POST 'localhost:8000/gungi/create' \
--header 'Content-Type: application/json' \
--data-raw '{
    "players": [
        { "unkonwnField": "asdf" },
        { "id": "asdf", "noName": "noNom" }
    ]
}'
  • 4 - less than expected player number
curl --location --request POST 'localhost:8000/gungi/create' \
--header 'Content-Type: application/json' \
--data-raw '{
    "players": [
        { "id": "id1", "name": "nameOne" }
    ]
}'
  • 5 - more than expected player number
curl --location --request POST 'localhost:8000/gungi/create' \
--header 'Content-Type: application/json' \
--data-raw '{
    "players": [
        { "id": "id1", "name": "nameOne" },
        { "id": "id2", "name": "nameOne" },
        { "id": "id3", "name": "nameOne" }
    ]
}'

server/src/usecases/Repository.ts Outdated Show resolved Hide resolved
server/src/frameworks/data-services/GungiRepository.ts Outdated Show resolved Hide resolved
@zhihdd zhihdd force-pushed the feature/15-create-gungi-game-v2 branch from 2bc1ec7 to b4072cc Compare November 14, 2023 14:06
Copy link
Contributor

@noracami noracami left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@bradychen2 bradychen2 left a comment

Choose a reason for hiding this comment

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

look good to me

@zhihdd zhihdd merged commit 734db1e into main Nov 14, 2023
6 checks passed
@zhihdd zhihdd deleted the feature/15-create-gungi-game-v2 branch November 14, 2023 14:13
@zhihdd zhihdd mentioned this pull request Nov 14, 2023
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.

4 participants