{"id":20925227,"url":"https://github.com/antonharbers/demo-node-server","last_synced_at":"2026-06-22T02:31:47.800Z","repository":{"id":180121183,"uuid":"664624658","full_name":"AntonHarbers/Demo-Node-Server","owner":"AntonHarbers","description":"Demo Node Server - The Odin Project: https://www.theodinproject.com/lessons/nodejs-basic-informational-site","archived":false,"fork":false,"pushed_at":"2024-01-03T14:27:48.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-20T11:31:17.669Z","etag":null,"topics":["client","html","javascript","nodejs","server"],"latest_commit_sha":null,"homepage":"https://odin-node-site.tmonee23.repl.co/","language":"HTML","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/AntonHarbers.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":"2023-07-10T11:45:31.000Z","updated_at":"2023-12-13T15:37:45.000Z","dependencies_parsed_at":"2023-12-13T16:39:54.015Z","dependency_job_id":"155bf78c-8ac2-4225-81d1-73e3d7cbea77","html_url":"https://github.com/AntonHarbers/Demo-Node-Server","commit_stats":null,"previous_names":["antonharbers/odin-node-site"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AntonHarbers/Demo-Node-Server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonHarbers%2FDemo-Node-Server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonHarbers%2FDemo-Node-Server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonHarbers%2FDemo-Node-Server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonHarbers%2FDemo-Node-Server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AntonHarbers","download_url":"https://codeload.github.com/AntonHarbers/Demo-Node-Server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonHarbers%2FDemo-Node-Server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34632542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["client","html","javascript","nodejs","server"],"created_at":"2024-11-18T20:29:52.964Z","updated_at":"2026-06-22T02:31:47.774Z","avatar_url":"https://github.com/AntonHarbers.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Odin Project - Basic Informational Site\n\nA simple multi page informational site built using node js, html and javascript for the odin Project.\n\n```\n    The 'express' branch showcases the same project written using the express application.\n\n    In order to run the express app, clone the express branch, install all node dependencies and run:\n\n    npm run start\n\n    In your console.\n\n```\n\n[Live Link](https://odin-node-site.tmonee23.repl.co/)\n\n![Landing Page](/repoImages/landingPage.png)\n![Contact Me](/repoImages/contactMe.png)\n![About](/repoImages/about.png)\n![Error](/repoImages/error.png)\n\n## Manual\n\nIf you clone this repo and want to try it out just make sure you have the correct node version installed and run the following command in your terminal from the root directory of this project.\n\nCMD:\n\n```\n    node index.js\n```\n\n## Folder Structure\n\n```\n    /.git               -\u003e This git repository\n    /repoImages         -\u003e Contains the images shown in this repo\n    404.html            -\u003e Error Page\n    about.html          -\u003e About Page\n    contact-me.html     -\u003e Contact Page\n    index.html          -\u003e Landing Page\n    index.js            -\u003e Server File\n    README.md           -\u003e This Readme\n```\n\n## Key Concepts\n\n### Node Server\n\nThis project was all about setting up a basic node server to serve html files to the client based on the given url path. This was acheived using nodejs and the HTTP and FS APIs (more on this below).\n\nTo set up node JS follow the instructions on their page: [Getting Started NodeJS](https://nodejs.org/en/learn/getting-started/how-to-install-nodejs)\n\n### HTTP and URL APIs\n\nI used the HTTP and URL APIs to create a server on port 8080 that takes requests and gives responses based on the path provided in our url:\n\nJS:\n\n```\nvar http = require('http');\nvar url = require('url');\n\nhttp\n  .createServer(function (req, res) {\n    var q = url.parse(req.url, true);\n    var filename = '.' + q.pathname;\n\n    switch (filename) {\n      case './':\n        filename = 'index.html';\n        break;\n      case './about':\n        filename = 'about.html';\n        break;\n      case './contact-me':\n        filename = 'contact-me.html';\n        break;\n      default:\n        filename = '404.html';\n        break;\n    }\n\n})\n.listen(8080);\n\n```\n\n### FS API\n\nThe FS API can then be used to return a response with a header and content (if there is not an error trying to read the file with the filename provided from the url and http APIs).\n\nJS:\n\n```\n    var fs = require('fs'); // IMPORT HERE\n\n    // ADD this to the inside of your .createServer function above to give a response to the client\n    fs.readFile(filename, function (err, data) {\n      if (err) {\n        res.writeHead(500, { 'Content-Type': 'text/plain' });\n        res.end('500 - Internal Server Error');\n      } else {\n        res.writeHead(200, { 'Content-Type': 'text/html' });\n        res.write(data);\n        return res.end();\n      }\n    });\n```\n\n## Final Notes\n\nA great first look at how to serve html documents to a client through a http server. NodeJs gives you great APIs and a runtime that makes all this super easy. It's a little verbose to do it this way in a time of modern frameworks, however I think its a great entry point and good foundational knowledge to help understand what these modern tools do behind the scenes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonharbers%2Fdemo-node-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonharbers%2Fdemo-node-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonharbers%2Fdemo-node-server/lists"}