{"id":875,"date":"2025-05-08T07:32:17","date_gmt":"2025-05-08T07:32:17","guid":{"rendered":"https:\/\/www.wordpress-prod.sharpener.tech\/?p=875"},"modified":"2025-05-24T14:54:22","modified_gmt":"2025-05-24T14:54:22","slug":"clean-up-using-routes-script","status":"publish","type":"post","link":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/","title":{"rendered":"Clean Up using routes Script"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/www.wordpress-prod.sharpener.tech\/wp-content\/uploads\/2025\/05\/Clean-Up-using-routes-Script-1024x683.jpg\" alt=\"\" class=\"wp-image-876\" srcset=\"https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/08073151\/Clean-Up-using-routes-Script-1024x683.jpg 1024w, https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/08073151\/Clean-Up-using-routes-Script-300x200.jpg 300w, https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/08073151\/Clean-Up-using-routes-Script-768x512.jpg 768w, https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/08073151\/Clean-Up-using-routes-Script.jpg 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Lecture Script: Refactoring Route Handling Using <\/strong><strong>module.exports<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Hi everyone! I hope everyone is doing fine.My name is Julian, and today we\u2019re going to clean up our code and make it more organized.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Right now, our code works just fine. But imagine if we had to handle 100 different endpoints! It could get really hard to manage if everything was in one place.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of it like moving into a new house and placing all your stuff\u2014clothes, kitchen items , books, your gym equipments\u2014into one room.&nbsp;<br>At first, it seems okay.<br>But when you need something, like a spoon or your shoes,<br>it gets tough to find in that mess.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Our code is just like that.<br>If we keep everything in one file,<br>it becomes messy and hard to manage as it grows.<br>That\u2019s why today we\u2019ll learn how to organize our code so it stays clean and it\u2019s easy to work with.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;Right now, we have all the routing logic inside app.js, but this can get messy as our project grows.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Instead of putting all the routes in app.js, we&#8217;ll move them into a new file called routes.js. This will keep things tidy and easier to work with.&#8221;<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Enroll in Sharpener NOW !<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">At&nbsp;<strong>Sharpener Tech<\/strong>, we don\u2019t just teach, we transform<strong>&nbsp;careers<\/strong>! Our&nbsp;<a href=\"https:\/\/www.sharpener.tech\/\"><strong>Pay After Placement<\/strong><\/a>&nbsp;model ensures&nbsp;<strong>ZERO financial risk<\/strong>&nbsp;you pay only when you land a high-paying job. With&nbsp;<strong>industry-driven Full Stack Development training<\/strong>, hands-on projects, and expert mentorship, we&nbsp;<strong>guarantee your success<\/strong>&nbsp;in the tech world. Don\u2019t just dream&nbsp;<strong>BUILD your future with Sharpener Tech!<\/strong>&nbsp;&nbsp;<strong>Apply now and start your journey!<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sharpenerian\u2019s work at the best companies!<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"429\" src=\"https:\/\/www.wordpress-prod.sharpener.tech\/wp-content\/uploads\/2025\/05\/Sharpener-works--1024x429.png\" alt=\"Sharpenerians work at the best companies\" class=\"wp-image-1059\" srcset=\"https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/13092711\/Sharpener-works--1024x429.png 1024w, https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/13092711\/Sharpener-works--300x126.png 300w, https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/13092711\/Sharpener-works--768x321.png 768w, https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/13092711\/Sharpener-works-.png 1534w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-fe48e5de wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/student.sharpener.tech\/register?blogName=clean-up-using-routes-script\">Register Now<\/a><\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Current Setup<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s start by looking at how our code is set up right now. Inside app.js, we have something like this:&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">javascript<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Copy code<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">const http = require(&#8216;http&#8217;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">const server = http.createServer((req, res) =&gt; {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;const url = req.url;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;if (url === &#8216;\/&#8217;) {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res.write(&#8216;&lt;html&gt;&lt;head&gt;&lt;title&gt;Home&lt;\/title&gt;&lt;\/head&gt;&lt;body&gt;&lt;h1&gt;Welcome to the Home Page&lt;\/h1&gt;&lt;\/body&gt;&lt;\/html&gt;&#8217;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return res.end();<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;if (url === &#8216;\/about&#8217;) {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res.write(&#8216;&lt;html&gt;&lt;head&gt;&lt;title&gt;About&lt;\/title&gt;&lt;\/head&gt;&lt;body&gt;&lt;h1&gt;About Us&lt;\/h1&gt;&lt;\/body&gt;&lt;\/html&gt;&#8217;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return res.end();<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">});<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">server.listen(3000);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here, we&#8217;re checking the URL and sending different responses for different routes. It works, but it can get messy if we add more routes. So, let\u2019s move this routing logic to another file.&#8221;<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Creating <\/strong><strong>routes.js<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First, create a new file called routes.js. Inside this file, we will write the routing logic.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In routes.js, add the following code:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">const requestHandler = (req, res) =&gt; {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;const url = req.url;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;if (url === &#8216;\/&#8217;) {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res.write(&#8216;&lt;html&gt;&lt;head&gt;&lt;title&gt;Home&lt;\/title&gt;&lt;\/head&gt;&lt;body&gt;&lt;h1&gt;Welcome to the Home Page&lt;\/h1&gt;&lt;\/body&gt;&lt;\/html&gt;&#8217;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return res.end();<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;if (url === &#8216;\/about&#8217;) {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res.write(&#8216;&lt;html&gt;&lt;head&gt;&lt;title&gt;About&lt;\/title&gt;&lt;\/head&gt;&lt;body&gt;&lt;h1&gt;About Us&lt;\/h1&gt;&lt;\/body&gt;&lt;\/html&gt;&#8217;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return res.end();<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">};<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">module.exports = requestHandler;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here, we moved our route handling to the routes.js file. We also used module.exports to make the requestHandler function available for other files.&#8221;<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Updating <\/strong><strong>app.js<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now, let\u2019s go back to app.js. Instead of writing the routes here, we will import the requestHandler from routes.js.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Modify app.js like this:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">javascript<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Copy code<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">const http = require(&#8216;http&#8217;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\/\/ Import the request handler from routes.js<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">const routes = require(&#8216;.\/routes&#8217;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">const server = http.createServer(routes);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">server.listen(3000);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We imported the requestHandler using require(&#8216;.\/routes&#8217;). This allows us to use the routing logic from routes.js. Now, our app.js only handles starting the server.&#8221;<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Why Is This Useful?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By doing this, we keep our code more organized. All the routing is in one file (routes.js), and starting the server is in another (app.js). This way, as the project grows, our code stays clean and easy to manage.&#8221;<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5: More on <\/strong><strong>module.exports<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can also export more than just one function. For now, we\u2019re only exporting the requestHandler function, but later on, you might export other functions or objects too.&#8221;<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To sum up, we learned how to:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Move routing logic to a separate file.<\/li>\n\n\n\n<li>Use module.exports to export a function.<\/li>\n\n\n\n<li>Import that function into app.js.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">This makes our code modular and easier to work with.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lecture Script: Refactoring Route Handling Using module.exports Hi everyone! I hope everyone is doing fine.My name is Julian, and today we\u2019re going to clean up our code and make it&hellip;<\/p>\n","protected":false},"author":6,"featured_media":876,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-875","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Clean Up Your Code Using Routes in Node.js | Organized Routing Script Guide<\/title>\n<meta name=\"description\" content=\"Learn how to clean up and organize your Node.js project using route scripts. Improve code structure, scalability, and maintainability with this simple routing guide.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Clean Up Your Code Using Routes in Node.js | Organized Routing Script Guide\" \/>\n<meta property=\"og:description\" content=\"Learn how to clean up and organize your Node.js project using route scripts. Improve code structure, scalability, and maintainability with this simple routing guide.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/\" \/>\n<meta property=\"og:site_name\" content=\"Sharpener Tech\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-08T07:32:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-24T14:54:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/08073151\/Clean-Up-using-routes-Script.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1536\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Julian Toppo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Julian Toppo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/\"},\"author\":{\"name\":\"Julian Toppo\",\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/#\\\/schema\\\/person\\\/eb9482df421e52d30f961eae8a0fd67a\"},\"headline\":\"Clean Up using routes Script\",\"datePublished\":\"2025-05-08T07:32:17+00:00\",\"dateModified\":\"2025-05-24T14:54:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/\"},\"wordCount\":922,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/08073151\\\/Clean-Up-using-routes-Script.jpg\",\"articleSection\":[\"Tips\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/\",\"url\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/\",\"name\":\"Clean Up Your Code Using Routes in Node.js | Organized Routing Script Guide\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/08073151\\\/Clean-Up-using-routes-Script.jpg\",\"datePublished\":\"2025-05-08T07:32:17+00:00\",\"dateModified\":\"2025-05-24T14:54:22+00:00\",\"description\":\"Learn how to clean up and organize your Node.js project using route scripts. Improve code structure, scalability, and maintainability with this simple routing guide.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/#primaryimage\",\"url\":\"https:\\\/\\\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/08073151\\\/Clean-Up-using-routes-Script.jpg\",\"contentUrl\":\"https:\\\/\\\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/08073151\\\/Clean-Up-using-routes-Script.jpg\",\"width\":1536,\"height\":1024},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/clean-up-using-routes-script\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Clean Up using routes Script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/\",\"name\":\"Sharpener Tech\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/#organization\",\"name\":\"Sharpener Tech\",\"url\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/wordpress-prod.sharpener.tech\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/Sharpener_logo-removebg-preview.png\",\"contentUrl\":\"https:\\\/\\\/wordpress-prod.sharpener.tech\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/Sharpener_logo-removebg-preview.png\",\"width\":187,\"height\":62,\"caption\":\"Sharpener Tech\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/#\\\/schema\\\/person\\\/eb9482df421e52d30f961eae8a0fd67a\",\"name\":\"Julian Toppo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/87799fed7134aa3bb27606b4eceeb577117023517d38b0152340c9e59376052c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/87799fed7134aa3bb27606b4eceeb577117023517d38b0152340c9e59376052c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/87799fed7134aa3bb27606b4eceeb577117023517d38b0152340c9e59376052c?s=96&d=mm&r=g\",\"caption\":\"Julian Toppo\"},\"url\":\"https:\\\/\\\/www.sharpener.tech\\\/blog\\\/author\\\/julian\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Clean Up Your Code Using Routes in Node.js | Organized Routing Script Guide","description":"Learn how to clean up and organize your Node.js project using route scripts. Improve code structure, scalability, and maintainability with this simple routing guide.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/","og_locale":"en_US","og_type":"article","og_title":"Clean Up Your Code Using Routes in Node.js | Organized Routing Script Guide","og_description":"Learn how to clean up and organize your Node.js project using route scripts. Improve code structure, scalability, and maintainability with this simple routing guide.","og_url":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/","og_site_name":"Sharpener Tech","article_published_time":"2025-05-08T07:32:17+00:00","article_modified_time":"2025-05-24T14:54:22+00:00","og_image":[{"width":1536,"height":1024,"url":"https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/08073151\/Clean-Up-using-routes-Script.jpg","type":"image\/jpeg"}],"author":"Julian Toppo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Julian Toppo","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/#article","isPartOf":{"@id":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/"},"author":{"name":"Julian Toppo","@id":"https:\/\/www.sharpener.tech\/blog\/#\/schema\/person\/eb9482df421e52d30f961eae8a0fd67a"},"headline":"Clean Up using routes Script","datePublished":"2025-05-08T07:32:17+00:00","dateModified":"2025-05-24T14:54:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/"},"wordCount":922,"commentCount":0,"publisher":{"@id":"https:\/\/www.sharpener.tech\/blog\/#organization"},"image":{"@id":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/#primaryimage"},"thumbnailUrl":"https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/08073151\/Clean-Up-using-routes-Script.jpg","articleSection":["Tips"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/","url":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/","name":"Clean Up Your Code Using Routes in Node.js | Organized Routing Script Guide","isPartOf":{"@id":"https:\/\/www.sharpener.tech\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/#primaryimage"},"image":{"@id":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/#primaryimage"},"thumbnailUrl":"https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/08073151\/Clean-Up-using-routes-Script.jpg","datePublished":"2025-05-08T07:32:17+00:00","dateModified":"2025-05-24T14:54:22+00:00","description":"Learn how to clean up and organize your Node.js project using route scripts. Improve code structure, scalability, and maintainability with this simple routing guide.","breadcrumb":{"@id":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/#primaryimage","url":"https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/08073151\/Clean-Up-using-routes-Script.jpg","contentUrl":"https:\/\/sharpener-wordpress.s3.ap-south-1.amazonaws.com\/blog\/wp-content\/uploads\/2025\/05\/08073151\/Clean-Up-using-routes-Script.jpg","width":1536,"height":1024},{"@type":"BreadcrumbList","@id":"https:\/\/www.sharpener.tech\/blog\/clean-up-using-routes-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sharpener.tech\/blog\/"},{"@type":"ListItem","position":2,"name":"Clean Up using routes Script"}]},{"@type":"WebSite","@id":"https:\/\/www.sharpener.tech\/blog\/#website","url":"https:\/\/www.sharpener.tech\/blog\/","name":"Sharpener Tech","description":"","publisher":{"@id":"https:\/\/www.sharpener.tech\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sharpener.tech\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.sharpener.tech\/blog\/#organization","name":"Sharpener Tech","url":"https:\/\/www.sharpener.tech\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sharpener.tech\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/wordpress-prod.sharpener.tech\/wp-content\/uploads\/2026\/05\/Sharpener_logo-removebg-preview.png","contentUrl":"https:\/\/wordpress-prod.sharpener.tech\/wp-content\/uploads\/2026\/05\/Sharpener_logo-removebg-preview.png","width":187,"height":62,"caption":"Sharpener Tech"},"image":{"@id":"https:\/\/www.sharpener.tech\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.sharpener.tech\/blog\/#\/schema\/person\/eb9482df421e52d30f961eae8a0fd67a","name":"Julian Toppo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/87799fed7134aa3bb27606b4eceeb577117023517d38b0152340c9e59376052c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/87799fed7134aa3bb27606b4eceeb577117023517d38b0152340c9e59376052c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/87799fed7134aa3bb27606b4eceeb577117023517d38b0152340c9e59376052c?s=96&d=mm&r=g","caption":"Julian Toppo"},"url":"https:\/\/www.sharpener.tech\/blog\/author\/julian\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/posts\/875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/comments?post=875"}],"version-history":[{"count":4,"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/posts\/875\/revisions"}],"predecessor-version":[{"id":1401,"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/posts\/875\/revisions\/1401"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/media\/876"}],"wp:attachment":[{"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/media?parent=875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/categories?post=875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sharpener.tech\/blog\/wp-json\/wp\/v2\/tags?post=875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}