{"id":21431540,"url":"https://github.com/tomdoestech/rest-api-tutorial-updated","last_synced_at":"2025-04-12T18:47:56.082Z","repository":{"id":37008026,"uuid":"412958414","full_name":"TomDoesTech/REST-API-Tutorial-Updated","owner":"TomDoesTech","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-19T17:24:12.000Z","size":157,"stargazers_count":598,"open_issues_count":5,"forks_count":286,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-04-03T20:13:16.375Z","etag":null,"topics":["mongodb","nodejs","rest-api","tutorial","typescript","zod"],"latest_commit_sha":null,"homepage":"https://www.youtube.com/watch?v=BWUi6BS9T5Y","language":"TypeScript","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/TomDoesTech.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":"2021-10-03T02:35:33.000Z","updated_at":"2025-03-25T15:28:28.000Z","dependencies_parsed_at":"2024-11-02T16:19:38.230Z","dependency_job_id":null,"html_url":"https://github.com/TomDoesTech/REST-API-Tutorial-Updated","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomDoesTech%2FREST-API-Tutorial-Updated","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomDoesTech%2FREST-API-Tutorial-Updated/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomDoesTech%2FREST-API-Tutorial-Updated/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomDoesTech%2FREST-API-Tutorial-Updated/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomDoesTech","download_url":"https://codeload.github.com/TomDoesTech/REST-API-Tutorial-Updated/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248617835,"owners_count":21134197,"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","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":["mongodb","nodejs","rest-api","tutorial","typescript","zod"],"created_at":"2024-11-22T23:07:59.636Z","updated_at":"2025-04-12T18:47:56.057Z","avatar_url":"https://github.com/TomDoesTech.png","language":"TypeScript","readme":"# Build a REST API with Node.js, Mongoose \u0026 TypeScript\n\nNote: This repository includes the [postman collection for the finished API](postman_collection.json)\n\nNote 2: Make sure you add .env to your .gitignore before pushing any changes to your repository. You will also want to generate new public \u0026 private keys\n\n#### Generate new keys: https://travistidwell.com/jsencrypt/demo/\n\n#### Base64 encode the keys: https://www.base64encode.org/\n\n\n\n## Common issues\n* I'm getting a JWT malformed error: https://youtu.be/FzKrfwplips\n* Managing environment variables: https://youtu.be/gfyQzeBlLTI\n\n## Who is this tutorial for?\n* Junior to mid-level developers\n* Anyone interested in building REST APIs with TypeScript\n\n## What you will need\n* A running instance of MongoDB\n* Postman\n* An IDE or text editor (VS Code)\n* A web browser\n* A package manager such as NPM or Yarn\n* Node.js installed\n\n## What next?\n* Testing the API with Jest\n* Build a React.js user interface\n* Add Prometheus metrics to the API\n* Deploy the API with Caddy \u0026 Docker\n* Add Google OAuth\n\n## Concepts\n* REST API principals\n    * CRUD\n    * HTTP methods\n* JWT \u0026 refresh tokens\n* Request validation\n## Technologies\n* Node.js\n* MongoDB with Mongoose\n* TypeScript\n* Express.js \u0026 Express.js middleware\n* Zod validation\n\n## Video structure\n1. What are we going to build (Postman demo)\n2. Code walk-through\n3. Bootstrap application\n   1. Setup express JS\n   2. Create routes function\n   3. Setup database connection\n   4. Setup logger\n   5. Validate request middleware\n4. Registration\n   1. Create user model\n   2. Create user endpoint\n   3. Create user session\n   4. Deserialize user middleware (refresh tokens)\n   5. Get sessions\n   6. Delete session\n   7. Require user middleware\n5. Product resource\n   1. Create product model\n   2. Create product\n   3. Read product\n   4. Update product\n   5. Delete product\n\n\n## Data flow\n![](./diagrams/data-flow.png)\n\n\n## Access \u0026 refresh token flow\n![](./diagrams/refresh-token-flow.png)\n\n\n# Deployment\n\n## What will we use\n* Docker (image)\n* docker-compose (container)\n* Caddy - Web server\n* DigitalOcean\n\nNote: You will need Docker installed locally if you want to test your Docker configutation\n\n## Let's keep in touch\n- [Subscribe on YouTube](https://www.youtube.com/TomDoesTech)\n- [Discord](https://discord.gg/4ae2Esm6P7)\n- [Twitter](https://twitter.com/tomdoes_tech)\n- [TikTok](https://www.tiktok.com/@tomdoestech)\n- [Facebook](https://www.facebook.com/tomdoestech)\n- [Instagram](https://www.instagram.com/tomdoestech)\n\n[Buy me a Coffee](https://www.buymeacoffee.com/tomn)\n\n[Sign up to DigitalOcean 💖](https://m.do.co/c/1b74cb8c56f4)\n","funding_links":["https://www.buymeacoffee.com/tomn"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomdoestech%2Frest-api-tutorial-updated","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomdoestech%2Frest-api-tutorial-updated","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomdoestech%2Frest-api-tutorial-updated/lists"}