-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix a few typos #2697
Fix a few typos #2697
Conversation
|
@@ -218,11 +218,11 @@ Description of the code: | |||
* [licenses.js](https://github.com/badges/shields/blob/master/lib/licenses.js) | |||
* [text-formatters.js](https://github.com/badges/shields/blob/master/lib/text-formatters.js) | |||
* [version.js](https://github.com/badges/shields/blob/master/lib/version.js) | |||
4. We perform input validation by defining a schema which we expect the JSON we receive to conform to. This is done using [Joi](https://github.com/hapijs/joi). Defining a schema means we can ensure the JSON we receive meets our expectations and throw an error if we receive unexpected input without having to explicitly code validation checks. The schema also acts as a filter on the JSON object. Any properties we're going to reference need to be validated, otherwise they will be filtered out. In this case our schema declares that we expect to recieve an object which must have a property called 'status', which is a string. | |||
4. We perform input validation by defining a schema which we expect the JSON we receive to conform to. This is done using [Joi](https://github.com/hapijs/joi). Defining a schema means we can ensure the JSON we receive meets our expectations and throw an error if we receive unexpected input without having to explicitly code validation checks. The schema also acts as a filter on the JSON object. Any properties we're going to reference need to be validated, otherwise they will be filtered out. In this case our schema declares that we expect to receive an object which must have a property called 'status', which is a string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub doesn't highlight the actual change in this line, so here it is in shorter form:
- to recieve an object
+ to receive an object
5. Our module exports a class which extends `BaseJsonService` | ||
6. As with our previous badge, we need to declare a route. This time we will capture a variable called `gem`. | ||
7. We can use `defaultBadgeData()` to set a default `color`, `logo` and/or `label`. If `handle()` doesn't return any of these keys, we'll use the default. Instead of explicitly setting the label text when we return a badge object, we'll use `defaultBadgeData()` here to define it declaratively. | ||
8. Our bage must implement the `async handle()` function. Because our URL pattern captures a variable called `gem`, our function signature is `async handle({ gem })`. We usually separate the process of generating a badge into 2 stages or concerns: fetch and render. The `fetch()` function is responsible for calling an API endpoint to get data. The `render()` function formats the data for display. In a case where there is a lot of calculation or intermediate steps, this pattern may be thought of as fetch, transform, render and it might be necessary to define some helper functions to assist with the 'transform' step. | ||
8. Our badge must implement the `async handle()` function. Because our URL pattern captures a variable called `gem`, our function signature is `async handle({ gem })`. We usually separate the process of generating a badge into 2 stages or concerns: fetch and render. The `fetch()` function is responsible for calling an API endpoint to get data. The `render()` function formats the data for display. In a case where there is a lot of calculation or intermediate steps, this pattern may be thought of as fetch, transform, render and it might be necessary to define some helper functions to assist with the 'transform' step. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub doesn't highlight the actual change in this line, so here it is in shorter form:
- Our bage must
+ Our badge must
Thank you! |
Many thanks for the quick review @paulmelnikow ! 💯 |
If you're interested in some kinda fun yet kinda robotic work, we need to convert all of our |
Thanks for the suggestion! I might look into it afterwards, but I'm already working on another PR for Shields (I'd like to make contributions easier by allowing anyone to develop Shields in Gitpod, a free dev environment service, and will probably also suggest a new badge for that service). I do have one question though, |
Interesting! :8080 is the badge server and :3000 is the frontend. Added: I'm not completely clear on how the Gitpod thing would work, though we like making it easier for people to contribute to Shields! If you need help while you're playing with it, feel free to open a new issue. |
@paulmelnikow Thanks for the suggestion! I opened #2772 with a bit more details, and my first roadblock (i.e. is there a way to expose the badge server on port 8080 for non-localhost access?) |
Most typos were fixed using
codespell -w
.