﻿
{"id":8783,"date":"2018-07-30T10:23:24","date_gmt":"2018-07-30T10:23:24","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=8783"},"modified":"2018-07-30T10:23:24","modified_gmt":"2018-07-30T10:23:24","slug":"express-jsde-routing-islemleri","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/express-jsde-routing-islemleri\/","title":{"rendered":"Express.js&#8217;de Routing \u0130\u015flemleri"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>Bu makalemizde web platformundaki t\u00fcm uygulamlarda en kritik husus olan, kullan\u0131c\u0131 etkilemi\u015finin en temel unsuru ve SEO a\u00e7\u0131s\u0131ndan arama motorlar\u0131n\u0131n okunabilirlik derecesi bak\u0131m\u0131ndan olduk\u00e7a \u00f6nemsenen url yap\u0131lar\u0131n\u0131n \u015fematize edilmesi i\u00e7in kullan\u0131lan Routing mekanizmas\u0131n\u0131 Node.js framework\u00fcn\u00fcn Express.js mod\u00fcl\u00fc \u00e7er\u00e7evesinde de\u011ferlendiriyor olaca\u011f\u0131z.<\/p>\n<p>Bilindi\u011fi \u00fczere d\u00f6rt temel Http metodu mevcuttur. Bunlar;<\/p>\n<ol>\n<li>GET<\/li>\n<li>POST<\/li>\n<li>PUT<\/li>\n<li>DELETE<\/li>\n<\/ol>\n<p>Express.js&#8217;de bu temel http metotlar\u0131n\u0131n haricinde bir de &#8220;ALL&#8221; metodu mevcuttur. Bu metot gelen t\u00fcm istekleri kar\u015f\u0131lamas\u0131 i\u00e7in di\u011fer metotlar\u0131n i\u015flevini tek ba\u015f\u0131na bar\u0131nd\u0131rabilecek \u015fekilde olu\u015fturulmu\u015ftur.<\/p>\n<p>Express.js&#8217;de bu metotlar kullanarak routing rotalar\u0131 olu\u015fturulmaktad\u0131r. Bunu \u00f6nceki makalelerimizde ele ald\u0131\u011f\u0131m\u0131z gibi h\u0131zl\u0131ca burada da \u00f6rneklendirelim.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nconst express = require(&quot;express&quot;);\r\nconst app = express();\r\n\r\napp.get(&quot;\/users&quot;, (request, response) =&gt; {\r\n    response.send(`${request.url} : GET`);\r\n}).post(&quot;\/createuser&quot;, (request, response) =&gt; {\r\n    response.send(`${request.url} : POST`);\r\n}).put(&quot;\/updateuser&quot;, (request, response) =&gt; {\r\n    response.send(`${request.url} : PUT`);\r\n}).delete(&quot;\/removeuser&quot;, (request, response) =&gt; {\r\n    response.send(`${request.url} : DELETE`);\r\n});\r\n\r\napp.listen(1453, () =&gt; {\r\n    console.log(&quot;Yay\u0131n ba\u015flad\u0131...&quot;);\r\n});\r\n<\/pre>\n<p>G\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere route yap\u0131lar\u0131 yukar\u0131daki gibi olu\u015fturulmaktad\u0131r. Olu\u015fturulan bu istekleri &#8220;Postman&#8221; uygulamas\u0131yla denersek e\u011fer;<\/p>\n<table>\n<thead>\n<tr>\n<th>GET<\/th>\n<th>POST<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - GET\" width=\"355\" height=\"343\" class=\"aligncenter size-full wp-image-8791\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET.png 355w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-300x290.png 300w\" sizes=\"auto, (max-width: 355px) 100vw, 355px\" \/><\/a><\/td>\n<td><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-POST.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-POST.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - POST\" width=\"383\" height=\"340\" class=\"aligncenter size-full wp-image-8792\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-POST.png 383w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-POST-300x266.png 300w\" sizes=\"auto, (max-width: 383px) 100vw, 383px\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<thead>\n<tr>\n<th>PUT<\/th>\n<th>DELETE<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-PUT.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-PUT.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - PUT\" width=\"395\" height=\"341\" class=\"aligncenter size-full wp-image-8793\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-PUT.png 395w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-PUT-300x259.png 300w\" sizes=\"auto, (max-width: 395px) 100vw, 395px\" \/><\/a><\/td>\n<td><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-DELETE.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-DELETE.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - DELETE\" width=\"395\" height=\"339\" class=\"aligncenter size-full wp-image-8794\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-DELETE.png 395w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-DELETE-300x257.png 300w\" sizes=\"auto, (max-width: 395px) 100vw, 395px\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>g\u00f6rd\u00fc\u011f\u00fcn\u00fcz gibi ilgili rotalara isteklerimiz ba\u015far\u0131yla ger\u00e7ekle\u015ftirilmektedir.<\/p>\n<p>Express.js route yap\u0131lanmas\u0131nda belirli \u00f6zel karakterlerle rotalar\u0131m\u0131z\u0131 daha da \u00f6zelle\u015ftirebiliriz. Bu karakterler; &#8220;?&#8221;, &#8220;*&#8221; ve &#8220;+&#8221; operat\u00f6rleridir. \u015eimdi bu operat\u00f6rleri s\u0131ras\u0131yla incelersek e\u011fer;<\/p>\n<ul>\n<li>\n<strong>?<\/strong><br \/>\n&#8220;?&#8221; operat\u00f6r\u00fc, sa\u011f\u0131nda kullan\u0131ld\u0131\u011f\u0131 karakteri zorunlu olmaktan \u00e7\u0131kar\u0131r.<br \/>\n\u00d6rne\u011fin;<br \/>\n&#8220;Gen?\u00e7ay&#8221; de\u011ferini ele al\u0131rsak e\u011fer &#8216;n&#8217; karakteri olsada olur! olmasa da!<br \/>\n&#8220;Gen?\u00e7ay&#8221; = &#8220;Gen\u00e7ay&#8221; = &#8220;Ge\u00e7ay&#8221;<br \/>\nBenzer mant\u0131kla birden fazla karakter \u00fczerinde bu operat\u00f6r\u00fc kullanmak isterseniz ilgili ifadeleri parantez i\u00e7ine alman\u0131z yeterlidir.<br \/>\n&#8220;Ge(n\u00e7)ay&#8221; = &#8220;Gen\u00e7ay&#8221; = &#8220;Geay&#8221;<br \/>\nBurada dikkat edilmesi gereken husus birden fazla karakter \u00fczerinde \u00e7al\u0131\u015f\u0131rken ya o karakterlerin hepsi ifade i\u00e7erisinde olmayacak ya da hepsi olacak&#8230; Son \u00f6rne\u011fimizde bu uyar\u0131ya istinaden &#8220;Genay&#8221; ifadesinde hata ile kar\u015f\u0131la\u015f\u0131lacakt\u0131r.<\/p>\n<p>Kodsal \u00f6rnek vermemiz gerekirse;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\napp.get(&quot;\/use?rs&quot;, (request, response) =&gt; {\r\n    response.send(`${request.url} : GET`);\r\n});\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-1.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - GET\" width=\"346\" height=\"336\" class=\"aligncenter size-full wp-image-8800\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-1.png 346w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-1-300x291.png 300w\" sizes=\"auto, (max-width: 346px) 100vw, 346px\" \/><\/a><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\napp.get(&quot;\/u(se)?rs&quot;, (request, response) =&gt; {\r\n    response.send(`${request.url} : GET`);\r\n});\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-2.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - GET\" width=\"333\" height=\"340\" class=\"aligncenter size-full wp-image-8802\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-2.png 333w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-2-294x300.png 294w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><\/a>\n<\/li>\n<li>\n<strong>*<\/strong><br \/>\n* operat\u00f6r\u00fc kullan\u0131ld\u0131\u011f\u0131 yere herhangi bir de\u011feri\/ifadeyi getirmemizi sa\u011flayan bir operat\u00f6rd\u00fcr.<br \/>\n\u00d6rne\u011fin;<br \/>\n&#8220;Gen*\u00e7ay&#8221; ifadesinde &#8216;*&#8217; operat\u00f6r\u00fcn\u00fcn yerine herhangi bir ifade getirilebilir.<br \/>\n&#8220;Gen*\u00e7ay&#8221; = &#8220;Genn\u00e7ay&#8221; = &#8220;Gena\u00e7ay&#8221;&#8221; = &#8220;Genzmeceylan\u00e7ay&#8221; = &#8220;Gensebepsizbosyereayrilacaksan\u00e7ay&#8221; = vs. vs.<br \/>\nKodsal \u00f6rnek;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\napp.get(&quot;\/use*rs&quot;, (request, response) =&gt; {\r\n    response.send(`${request.url} : GET`);\r\n});\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-3.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - GET\" width=\"408\" height=\"335\" class=\"aligncenter size-full wp-image-8805\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-3.png 408w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-3-300x246.png 300w\" sizes=\"auto, (max-width: 408px) 100vw, 408px\" \/><\/a>\n<\/li>\n<li>\n<strong>+<\/strong><br \/>\n&#8220;+&#8221; operat\u00f6r\u00fc solundaki ifadenin ayn\u0131s\u0131n\u0131 \u00e7o\u011faltan bir operat\u00f6rd\u00fcr.<br \/>\n\u00d6rne\u011fin;<br \/>\n&#8220;Gen+\u00e7ay&#8221; ifadesinde &#8216;n&#8217; karakteri \u00e7o\u011falt\u0131larak &#8220;Gennnnn&#8230;\u00e7ay&#8221; \u015feklinde yaz\u0131labilir.<br \/>\nKodsal \u00f6rnek;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\napp.get(&quot;\/use+rs&quot;, (request, response) =&gt; {\r\n    response.send(`${request.url} : GET`);\r\n});\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-4.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - GET\" width=\"375\" height=\"420\" class=\"aligncenter size-full wp-image-8807\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-4.png 375w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-4-268x300.png 268w\" sizes=\"auto, (max-width: 375px) 100vw, 375px\" \/><\/a>\n<\/li>\n<\/ul>\n<h3>GET \u0130steklerine Parametre Atama<\/h3>\n<p>Gelen GET isteklerine Query String tarz\u0131nda parametre atamak i\u00e7in &#8220;:&#8221; operat\u00f6r\u00fcyle a\u015fa\u011f\u0131daki gibi bir de\u011fi\u015fken tan\u0131ml\u0131yoruz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\napp.get(&quot;\/user\/:id&quot;, (request, response) =&gt; {\r\n    response.send(request.params);\r\n});\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-5.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - GET\" width=\"356\" height=\"435\" class=\"aligncenter size-full wp-image-8815\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-5.png 356w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-5-246x300.png 246w\" sizes=\"auto, (max-width: 356px) 100vw, 356px\" \/><\/a><br \/>\nDikkat ederseniz e\u011fer &#8220;:&#8221; operat\u00f6r\u00fc ile &#8220;id&#8221; isimli bir de\u011fi\u015fken tan\u0131mlam\u0131\u015f bulunmaktay\u0131z. \u0130lgili de\u011fi\u015fkeleri ve de\u011ferlerini &#8220;request.params&#8221; komutuyla elde edebilmekteyiz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\napp.get(&quot;\/user\/:detail\/:id&quot;, (request, response) =&gt; {\r\n    response.send(`id : ${request.params.id} - detail : ${request.params.detail}`);\r\n    console.log();\r\n});\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-6.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-6.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - GET\" width=\"401\" height=\"399\" class=\"aligncenter size-full wp-image-8816\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-6.png 401w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-6-150x150.png 150w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-6-300x300.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-6-160x160.png 160w\" sizes=\"auto, (max-width: 401px) 100vw, 401px\" \/><\/a><\/p>\n<h3>Router Nesnesi \u0130le Route Y\u00f6netimi<\/h3>\n<p>\u00c7al\u0131\u015fmalar\u0131m\u0131zda birbirinden farkl\u0131 route yap\u0131lar\u0131n\u0131 tek bir s\u0131n\u0131f alt\u0131nda toplamak ileriye d\u00f6n\u00fck olduk\u00e7a kar\u0131\u015f\u0131k ve zay\u0131f y\u00f6netilebilir bir durum arz edecektir. Dolay\u0131s\u0131yla route yap\u0131lanmalar\u0131n\u0131 ilgili mod\u00fcllere b\u00f6lerek bu mod\u00fclleri Express.js&#8217;de ki Router nesnesi arac\u0131l\u0131\u011f\u0131yla bir b\u00fct\u00fcn olarak y\u00f6netmek \u00e7al\u0131\u015fmalar\u0131m\u0131zda olduk\u00e7a h\u0131zl\u0131 ve kar\u0131\u015f\u0131kl\u0131l\u0131\u011fa mahal vermeksizin anlaml\u0131 ilerlememizi sa\u011flayacakt\u0131r.<\/p>\n<p>\u015eimdi bir \u00f6rnek senaryo \u00fczerinden konuyu ele alal\u0131m. \u0130lk olarak birden fazla route yap\u0131s\u0131n\u0131 olu\u015fturaca\u011f\u0131m\u0131z s\u0131n\u0131flar\u0131m\u0131z\u0131 olu\u015ftural\u0131m.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/-user.js\r\nconst express = require(&quot;express&quot;);\r\nconst router = express.Router();\r\n\r\nrouter.get(&quot;\/getusers&quot;, (request, response) =&gt; {\r\n    response.send(`URL : ${request.url} | RequestType : GET`);\r\n}).post(&quot;\/adduser&quot;, (request, response) =&gt; {\r\n    response.send(`URL : ${request.url} | RequestType : POST`);\r\n});\r\n\r\nmodule.exports = router;\r\n<\/pre>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/-content.js\r\nconst express = require(&quot;express&quot;);\r\nconst router = express.Router();\r\n\r\nrouter.get(&quot;\/getcontent&quot;, (request, response) =&gt; {\r\n    response.send(`URL : ${request.url} | RequestType : GET`);\r\n}).post(&quot;\/addcontent&quot;, (request, response) =&gt; {\r\n    response.send(`URL : ${request.url} | RequestType : POST`);\r\n});\r\n\r\nmodule.exports = router;\r\n<\/pre>\n<p>S\u0131n\u0131flar\u0131m\u0131za dikkat ederseniz e\u011fer Express mod\u00fcl\u00fc i\u00e7erisindeki &#8220;Router&#8221; metodunu kullan\u0131larak bir route yap\u0131lanmas\u0131 olu\u015fturulmaktad\u0131r ve bu route yap\u0131s\u0131 &#8220;module.exports&#8221; ile di\u011fer mod\u00fcllere ta\u015f\u0131nmaktad\u0131r. Bu route yap\u0131lar\u0131n\u0131n kullan\u0131labilmesi i\u00e7in ilgili s\u0131n\u0131flara &#8220;require&#8221; edilmeleri ve a\u015fa\u011f\u0131daki gibi uygulamaya &#8220;use&#8221; fonksiyonuyla tan\u0131t\u0131lmalar\u0131 gerekmektedir.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nconst express = require(&quot;express&quot;);\r\nconst app = express();\r\nconst userRoutes = require(&quot;.\/user&quot;);\r\nconst contentRoutes = require(&quot;.\/content&quot;);\r\napp.use(&quot;\/&quot;, userRoutes);\r\napp.use(&quot;\/&quot;, contentRoutes);\r\n\r\napp.listen(1453, () =&gt; {\r\n    console.log(&quot;Yay\u0131n ba\u015flad\u0131...&quot;);\r\n});\r\n<\/pre>\n<p>Bu i\u015flemden sonra ilgili rotalara isteklerde bulunursak e\u011fer;<\/p>\n<table>\n<thead>\n<tr>\n<th>user.js<\/th>\n<th>content.js<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-7.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-7.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - GET\" width=\"371\" height=\"342\" class=\"aligncenter size-full wp-image-8829\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-7.png 371w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-7-300x277.png 300w\" sizes=\"auto, (max-width: 371px) 100vw, 371px\" \/><\/a><\/td>\n<td><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-9.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-9.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - GET\" width=\"391\" height=\"343\" class=\"aligncenter size-full wp-image-8831\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-9.png 391w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-9-300x263.png 300w\" sizes=\"auto, (max-width: 391px) 100vw, 391px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-8.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-8.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - GET\" width=\"373\" height=\"340\" class=\"aligncenter size-full wp-image-8830\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-8.png 373w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-GET-8-300x273.png 300w\" sizes=\"auto, (max-width: 373px) 100vw, 373px\" \/><\/a><\/td>\n<td><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-POST-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-POST-1.png\" alt=\"Express.js&#039;de Routing \u0130\u015flemleri - POST\" width=\"394\" height=\"340\" class=\"aligncenter size-full wp-image-8832\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-POST-1.png 394w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2018\/07\/Express.jsde-Routing-\u0130\u015flemleri-POST-1-300x259.png 300w\" sizes=\"auto, (max-width: 394px) 100vw, 394px\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>g\u00f6rsellerde oldu\u011fu gibi s\u0131k\u0131nt\u0131s\u0131z bir \u015fekilde \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131 g\u00f6receksiniz.<\/p>\n<p>Son olarak &#8220;use&#8221; fonksiyonunda verilen ilk parametrenin de\u011ferine g\u00f6re ilgili route yap\u0131lanmalar\u0131 ilgili de\u011ferin alt\u0131nda olacak \u015fekilde \u00e7a\u011fr\u0131lacakt\u0131rlar. \u015e\u00f6yle ki;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\napp.use(&quot;\/user\/&quot;, userRoutes);\r\napp.use(&quot;\/content\/&quot;, contentRoutes);\r\n<\/pre>\n<p>\u015feklinde tan\u0131mlama yap\u0131lsayd\u0131 &#8220;user.js&#8221; de ki urller &#8220;user\/****&#8221; \u015feklinde ve &#8220;content.js&#8221; de ki urller ise &#8220;content\/****&#8221; \u015feklinde olu\u015fturulmas\u0131 gerekecekti.<\/p>\n<p>Evet&#8230; Express.js&#8217;de routing i\u015flemlerini tam teferruatl\u0131 ele almaya \u00e7al\u0131\u015ft\u0131k. Faydalanman\u0131z dile\u011fiyle&#8230;<\/p>\n<p>Sonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, Bu makalemizde web platformundaki t\u00fcm uygulamlarda en kritik husus olan, kullan\u0131c\u0131 etkilemi\u015finin en temel unsuru ve SEO a\u00e7\u0131s\u0131ndan arama motorlar\u0131n\u0131n okunabilirlik derecesi bak\u0131m\u0131ndan olduk\u00e7a \u00f6nemsenen url yap\u0131lar\u0131n\u0131n \u015fematize edilmesi i\u00e7in kullan\u0131lan Routing mekanizmas\u0131n\u0131&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":8686,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2495,2145],"tags":[2142,2497,2516,2521,2520,2518,2519,2147,2517],"class_list":["post-8783","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-express-js","category-node-js","tag-http-get","tag-express-js","tag-express-js-routing","tag-http-all","tag-http-delete","tag-http-post","tag-http-put","tag-node-js","tag-node-js-routing"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/8783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=8783"}],"version-history":[{"count":36,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/8783\/revisions"}],"predecessor-version":[{"id":8838,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/8783\/revisions\/8838"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/8686"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=8783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=8783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=8783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}