{"id":20925222,"url":"https://github.com/antonharbers/blog-api-demo","last_synced_at":"2026-05-04T20:31:39.762Z","repository":{"id":217762711,"uuid":"744541084","full_name":"AntonHarbers/Blog-Api-Demo","owner":"AntonHarbers","description":"API Demo - The Odin Project: https://www.theodinproject.com/lessons/nodejs-blog-api","archived":false,"fork":false,"pushed_at":"2024-02-06T17:21:54.000Z","size":119,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T01:16:04.903Z","etag":null,"topics":["blog","demo","express","javascript","node","rest-api","routes","theodinproject"],"latest_commit_sha":null,"homepage":"https://cerulean-diagnostic-watercress.glitch.me/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","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":"LICENSE","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-01-17T14:08:59.000Z","updated_at":"2024-02-25T22:33:25.000Z","dependencies_parsed_at":"2024-01-18T06:16:23.104Z","dependency_job_id":"6451bf04-a88f-4f62-85cb-33ef6cffa076","html_url":"https://github.com/AntonHarbers/Blog-Api-Demo","commit_stats":null,"previous_names":["antonharbers/blog-api-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AntonHarbers/Blog-Api-Demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonHarbers%2FBlog-Api-Demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonHarbers%2FBlog-Api-Demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonHarbers%2FBlog-Api-Demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonHarbers%2FBlog-Api-Demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AntonHarbers","download_url":"https://codeload.github.com/AntonHarbers/Blog-Api-Demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntonHarbers%2FBlog-Api-Demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268338276,"owners_count":24234540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"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":["blog","demo","express","javascript","node","rest-api","routes","theodinproject"],"created_at":"2024-11-18T20:29:51.897Z","updated_at":"2026-05-04T20:31:34.736Z","avatar_url":"https://github.com/AntonHarbers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blog API - The Odin Project\n\nA simple backend only API made for the odin project. Made using express, passport and mongoDB.\n\n[Frontend App Repo](https://github.com/AntonHarbers/blog-frontend-demo)\n[Frontend App Live](https://famous-dolphin-e32fb4.netlify.app/)\n[Author Page Repo](https://github.com/AntonHarbers/blog-author-page-demo)\n[Author Page](https://blog-author-page-demo-osga3btfh-tmonee23.vercel.app/)\n[Rest-API Enpoint](https://cerulean-diagnostic-watercress.glitch.me/)\n\n## Key Concepts\n\nIn this Blog API, several key concepts are utilized to ensure a robust, secure, and efficient system. Below are some of the core concepts with examples:\n\n### JWT Authentication\n\nJSON Web Tokens (JWT) are used for securely transmitting information between parties as a JSON object. This is implemented in the authentication of users.\n\n**Example**:\n\n```javascript\nconst jwt = require('jsonwebtoken');\n\nexports.generateToken = (user) =\u003e {\n  return jwt.sign(\n    { userId: user._id, isAdmin: user.isAdmin },\n    process.env.JWT_SECRET,\n    { expiresIn: '1h' }\n  );\n};\n```\n\n### Password Hashing\n\nFor security, user passwords are hashed using bcrypt before storing in the database.\n\n**Example**:\n\n```javascript\nconst bcrypt = require('bcryptjs');\n\nasync function hashPassword(password) {\n  return await bcrypt.hash(password, 10);\n}\n```\n\n### Async/Await for Asynchronous Code\n\nAsync/Await is used to handle asynchronous operations, making the code cleaner and more readable.\n\n**Example**:\n\n```javascript\nasync function getUser(id) {\n  try {\n    return await User.findById(id);\n  } catch (error) {\n    // Handle error\n  }\n}\n```\n\n## API Route Documentation\n\nThis API provides various routes for handling blog-related functionalities:\n\n### Authentication Routes\n\n- `POST /auth/signup`: Registers a new user.\n- `POST /auth/login`: Authenticates a user and returns a JWT.\n- `GET /auth/logout`: Ends the user session (client-side token deletion).\n- `GET /auth/session`: Responds with users logged in status and how long the session will last.\n\n### User Routes\n\n- `GET /users`: Retrieves a list of users (admin only).\n- `GET /users/:id`: Retrieves a specific user's details.\n- `PUT /users/:id`: Updates a user's information.\n- `DELETE /users/:id`: Deletes a user account.\n\n### Post Routes\n\n- `GET /posts`: Retrieves all posts.\n- `GET /posts/:id`: Retrieves a specific post.\n- `POST /posts`: Creates a new post.\n- `PUT /posts/:id`: Updates a post.\n- `DELETE /posts/:id`: Deletes a post.\n\n### Comment Routes\n\n- `GET /comments`: Retrieves all comments.\n- `GET /comments/:id`: Retrieves a specific comment.\n- `POST /comments`: Adds a new comment to a post.\n- `PUT /comments/:id`: Updates a comment.\n- `DELETE /comments/:id`: Deletes a comment.\n\n## Final Notes\n\nThrough the development of this Blog API, I've gained valuable insights into backend development, especially in Node.js and Express. Key learnings include:\n\n- **Security Practices**: Implementing JWT for secure authentication and bcrypt for password hashing has emphasized the importance of security in web development.\n- **Asynchronous Programming**: Mastery of async/await has greatly improved the handling of asynchronous operations, making the code more readable and maintainable.\n- **RESTful API Design**: Developing a set of coherent and well-structured API endpoints has taught me the principles of RESTful design, crucial for scalable and efficient web services.\n\n### Real-World Applicability\n\nThe concepts and practices used in this project are directly applicable to real-world scenarios:\n\n- Building secure and scalable APIs for web applications.\n- Implementing authentication and authorization in e-commerce platforms, social networks, or any user-based application.\n- Utilizing async/await in managing database operations, external API calls, or any asynchronous tasks in server-side logic.\n\nThis project has been a stepping stone in my journey as a backend developer, solidifying my foundation and preparing me for more complex and impactful projects in the future.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonharbers%2Fblog-api-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonharbers%2Fblog-api-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonharbers%2Fblog-api-demo/lists"}