OneSignalDevelopers / ngosi

Share your slides with a QR code
https://ngosi.io
MIT License
9 stars 5 forks source link

Http status codes #27

Closed Yohanan-Negash closed 2 years ago

Yohanan-Negash commented 2 years ago

Fixes #15

Solution

Added the http-status-codes package as a dependency and replaced the use of the magic numbers with those status codes.

Testing

  1. Checkout dev branch, git checkout origin/dev
  2. Start the app, yarn dev
  3. Send a request to api/survey, note down the response status code (should be 200)
  4. Checkout this PR branch
  5. Install the new dependency, yarn
  6. Repeat steps 2 and 3
  7. Ensure you get the same result (200 OK)

Resources

HTTPie request to api/survey with HTTP request & response.

http POST localhost:3000/api/survey Content-Type:plain/text presoShortCode=Zjb4DKO --verbose

POST /api/survey HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 29
Content-Type: plain/text
Host: localhost:3000
User-Agent: HTTPie/2.6.0

{
    "presoShortCode": "Zjb4DKO"
}

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 452
Content-Type: application/json; charset=utf-8
Date: Tue, 28 Dec 2021 01:26:59 GMT
ETag: "1c4-hySNAItLfwhtQX1Vug/HeemFNOI"
Keep-Alive: timeout=5
Vary: Accept-Encoding

{
    "presenter": {
        "avatar_url": "",
        "id": "dfa0cde0-1afc-4621-a3cb-0323d95f35b3",
        "updated_at": "2021-12-26T20:03:38.928619+00:00",
        "username": "William Shepherd",
        "website": "https://codeincolor.io"
    },
    "preso": {
        "createdAt": "2021-12-26T20:06:26.845",
        "eventName": "Google IO",
        "id": "ckxnomm0c0000hpbg0ctzgxzp",
        "shortCode": "Zjb4DKO",
        "title": "How to Google",
        "updatedAt": "2021-12-26T20:06:26.845",
        "url": "https://google.com",
        "userId": "dfa0cde0-1afc-4621-a3cb-0323d95f35b3"
    }
}

References

vercel[bot] commented 2 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/onesignaldevs/ngosi/E6EtjReNEJj2eux4jiUwUFk1Kdb8
✅ Preview: https://ngosi-git-http-status-codes-onesignaldevs.vercel.app