{"id":24711774,"url":"https://github.com/sunthecoder/json-basics","last_synced_at":"2026-05-09T01:07:49.333Z","repository":{"id":245600979,"uuid":"818724940","full_name":"SunTheCoder/Json-Basics","owner":"SunTheCoder","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-22T17:20:27.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T06:45:18.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SunTheCoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-22T17:14:57.000Z","updated_at":"2024-06-22T17:20:30.000Z","dependencies_parsed_at":"2024-06-23T00:43:48.959Z","dependency_job_id":"a7cfd4f1-ea29-4c38-a129-20bf9a8e5e62","html_url":"https://github.com/SunTheCoder/Json-Basics","commit_stats":null,"previous_names":["sunthecoder/json-basics"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SunTheCoder/Json-Basics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SunTheCoder%2FJson-Basics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SunTheCoder%2FJson-Basics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SunTheCoder%2FJson-Basics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SunTheCoder%2FJson-Basics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SunTheCoder","download_url":"https://codeload.github.com/SunTheCoder/Json-Basics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SunTheCoder%2FJson-Basics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32803626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-27T07:15:52.982Z","updated_at":"2026-05-09T01:07:49.319Z","avatar_url":"https://github.com/SunTheCoder.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Practice: HTTP Basics in a JSON file\n\nIn this practice, you will document the request and response components for\nRESTful endpoints of a **traditional HTML web server** in a JSON file.\n\n## Set up\n\n1. Clone the practice from GitHub.\n2. Run `npm install` at the root of the project to install dependencies.\n\nTo set up the server that you will test endpoints on, `cd` inside of the\n**server** folder and run `npm install` inside of the **server** folder.\n\nThis is the same server you worked with previously in the HTTP Basics Long\nPractice. **Do not to look at the contents of the server folder until you finish\nthis exercise.**\n\nTo start the server, run `npm start` inside of the **server** folder. This will\nallow you to make requests to [http://localhost:5000] using any client, such as\nyour browser or Postman.\n\nTo stop the server from listening to requests, press `CTRL + c` for\nWindows/Linux or `CMD + c` for MacOS in the terminal that you started the server\n(wherever you ran `npm start`). To restart a stopped server, run `npm start`\nagain.\n\n\u003e Note: Make sure to stop the server when you are finished with this practice.\n\u003e Leaving a server running may prevent servers in other practices/exercises\n\u003e from starting properly.\n\n## Instructions\n\nDocument the server from the original [HTTP Basics practice] in the\n__answers.json__ JSON file provided to you.\n\nOnce you're finished, you can run ALL of the tests using `npm test` from the\nroot of the project.\n\nYou may also run each test individually, using `npm run test-\u003cNUM\u003e`, and\nreplacing `\u003cNUM\u003e` with a number between 01 and 15 (corresponding to the endpoint\nnumber in the __answers.json__ file).\n\n### Documentation\n\nThe documentation for this server should be written in the `answers.json` file\nprovided to you. For each endpoint listed below, list out the request and\nresponse components in the `answers.json` file.\n\n#### Headers Formatting\n\n**Include only necessary headers.**\n\nTo add a header as a component to the request or response, define the key and\nvalue of a header in a JSON object set to the `headers` key on the `request`\nor `response` object. **All the endpoints are RESTful endpoints for a\ntraditional web server.**\n\nHere's an example:\n\n```json\n\"headers\": {\n  \"Content-Type\": \"application/x-www-form-urlencoded\"\n}\n```\n\n#### Request Body Formatting\n\nTo add a `body` as a component to the request, define the data structure of the\n`body` (object, array, nested object, or nested array). The values for objects\nin the `body` must be a truthy value.\n\nHere's an example:\n\n```json\n\"body\": {\n  \"color\": true,\n  \"toolbox\": [\n    {\n      \"tool\": true\n    }\n  ]\n}\n```\n\n#### Response Body Formatting\n\nIf there is a response body for the endpoint, set the `body` key in the\n`response` object to `true` or a truthy value.\n\nHere's an example:\n\n```json\n\"body\": true\n```\n\n#### Removing a Component\n\nTo omit a component from the request or response, set the key of that request\nor response component to `false`.\n\nFor example, to omit the `headers` of the request, change the `headers` key from\n`null` to `false`.\n\n```json\n\"headers\": false,\n```\n\nTo omit the `body` of the request, change the `body` key from `null` to `false`.\n\n```json\n\"body\": false\n```\n\n## Reminders about an HTML Web Server\n\nHere are some reminders about an HTML web server.\n\nAn HTML web server displays web pages in which a user can make HTTP requests\nthrough HTML links and forms.\n\n### HTML form submission\n\nWhen an HTML form is submitted, the browser will make a request using the\ninformation on the form when submitted.\n\nThe `method` attribute on the HTML `\u003cform\u003e` element determines the method of the\nrequest. The only valid values for the `method` attribute are \"get\" and \"post\".\nThis is the reason why endpoints of a traditional HTML web servers will only\nhave `GET` or `POST` as methods.\n\nThe `action` attribute on the HTML `\u003cform\u003e` element determines the URL of the\nrequest.\n\nThe fields (form data) inside of HTML `\u003cform\u003e` element determine the body of the\nrequest. The form data in the request will be percent-encoded or URL-encoded.\nBecause of this, the `Content-Type` header of the request will be\n\"application/x-www-form-urlencoded\".\n\nFor example, if you have the following HTML form:\n\n```html\n\u003cform method=\"post\" action=\"/cat\"\u003e\n  \u003clabel\u003e\n    Name\n    \u003cinput type=\"text\" name=\"name\" /\u003e\n  \u003c/label\u003e\n  \u003clabel\u003e\n    Pattern\n    \u003cselect name=\"pattern\"\u003e\n      \u003coption value=\"tabby\"\u003eTabby\u003c/option\u003e\n      \u003coption value=\"striped\"\u003eStriped\u003c/option\u003e\n      \u003coption value=\"tortie\"\u003eTortie\u003c/option\u003e\n      \u003coption value=\"calico\"\u003eCalico\u003c/option\u003e\n      \u003coption value=\"bicolor\"\u003eBicolor\u003c/option\u003e\n    \u003c/select\u003e\n  \u003c/label\u003e\n  \u003clabel\u003e\n    Size\n    \u003cinput type=\"number\" name=\"size\" /\u003e\n  \u003c/label\u003e\n  \u003clabel\u003e\n    Description\n    \u003ctextarea name=\"description\"\u003e\u003c/textarea\u003e\n  \u003c/label\u003e\n  \u003cinput type=\"submit\" value=\"Create Cat\" /\u003e\n\u003c/form\u003e\n```\n\nIf you submit the HTML form above with the `name` field filled out as \"Fluffy\",\nthe `pattern` field as \"Calico\", the `size` field as 5, and the `description`\nfield as \"very fluffy\", then the following HTTP request will be made:\n\n```plaintext\nHTTP/1.1 POST /cat\nContent-Type: application/x-www-form-urlencoded\n\nname=Fluffy\u0026pattern=calico\u0026size5\u0026description=very+fluffy\n```\n\nAs a response to this type of request, the server will likely redirect the user.\n\n### Response components\n\nIn a traditional HTML web application, the response will either be an HTML web\npage, or a redirection.\n\nIn the case of a **response with the body containing an HTML web page**, the\nresponse may look something like this:\n\n```plaintext\nHTTP/1.1 200 OK\nContent-Type: text/html;\n\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n...\n...\n\u003c/html\u003e\n```\n\nThe status code of the response is 200, the `Content-Type` header is\n\"text/html\", and the body of the request is the HTML web page as a string.\n\nIn the case of a **response redirecting a user**, the response may look\nsomething like this:\n\n```plaintext\nHTTP/1.1 302 Found\nLocation: /url-to-redirect-to;\n```\n\nThe status code of the response is 302, the `Location` header is set to the URL\nwhich you want to redirect the user to, and there is no body in the response.\n\n### Headers\n\nThe only possible **request headers** of a traditional web application and their\nvalues are:\n\n- `Content-Type` (when the request has a body):\n  - \"application/x-www-form-urlencoded\"\n\nThe only possible **response headers** of a traditional web application and\ntheir values are:\n\n- `Content-Type` (when the response has a body):\n  - \"text/html\"\n- `Location` (when the server redirects):\n  - url that server wants to redirect the client to\n\n[HTTP Basics practice]: https://github.com/appacademy/practice-for-week-08-http-basics-long-practice\n# Json-Basics\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunthecoder%2Fjson-basics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunthecoder%2Fjson-basics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunthecoder%2Fjson-basics/lists"}