<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nabi Güzel on Medium]]></title>
        <description><![CDATA[Stories by Nabi Güzel on Medium]]></description>
        <link>https://medium.com/@nabiguzel?source=rss-12f126b4bcc5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PBvNsGQwH5KHmlvsEEZM1w.jpeg</url>
            <title>Stories by Nabi Güzel on Medium</title>
            <link>https://medium.com/@nabiguzel?source=rss-12f126b4bcc5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 08:15:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nabiguzel/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Web Sitenizde Huawei Map İle Konum Gösterme]]></title>
            <link>https://medium.com/@nabiguzel/web-sitenizde-huawei-map-ile-konum-gosterme-8a6de8e659e2?source=rss-12f126b4bcc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a6de8e659e2</guid>
            <category><![CDATA[navigation]]></category>
            <category><![CDATA[website]]></category>
            <category><![CDATA[map-marker]]></category>
            <category><![CDATA[huawei-map]]></category>
            <category><![CDATA[petal-maps]]></category>
            <dc:creator><![CDATA[Nabi Güzel]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 16:54:01 GMT</pubDate>
            <atom:updated>2023-01-20T16:54:01.506Z</atom:updated>
            <content:encoded><![CDATA[<p>Huawei MapKit API Kullanarak Web Uygulamanızı dinamik ve etkileşimli haritalarla zenginleştirip, haritada tıklanan işaretçi ile yönlendirilen Petal Maps üzerinden rota çizdirin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*HaHW8vNYTZVv-Ku2VUQJxQ.jpeg" /></figure><h3>Giriş</h3><p>Web sitelerinde gerekli durumlarda harita gösterimi iyi bir kullanıcı deneyimi sunmaktadır. Ayrıca gösterilen konuma tıklanması durumunda harita uygulaması açılması ve haritada gösterilen konuma rota oluşturulması bu deneyimi arttırmaktadır.</p><p>Bu yazımda web uygulamalarında ücretsiz harita gösterimi için kullanılacak en iyi alternatiflerden biri olan Huawei MapKit ile konum gösterimini nasıl yapacağımızı inceleyeceğiz. Ayrıca gösterilen konum işaretcisine tıklanması durumunda Petal Maps yönlendirmesi yapıp, açılan haritadan kullanıcı konumundan, gösterilen konuma yol tarifi çizdirmeyi de incelemiş olacağız.</p><h3>Ücretlendirme</h3><p>Huawei, harita gösterimini de içeren tüm PetalMaps ürünlerini kullanmak için her ay 300 dolar bonus veriyor. Bu sayede her ay yenilenen bu limit tutarı kadar ürünü ücretsiz kullanım hakkı elde etmiş oluyorsunuz. Bu limit temel bir kullanım için fazlası ile yeterli olmaktadır. Detaylı ücret bilgisine <a href="https://developer.petalmaps.com/price">linkten </a>erişebilirsiniz.</p><p><a href="https://developer.petalmaps.com/price">HUAWEI Petal Maps Platform - HUAWEI Developer</a></p><h3>API Key Oluşturma</h3><p>Harita servisini kullanabilmek için öncelikle bir API keye sahip olmalısınız bunun için aşağıdaki adımları izleyebilirsiniz.</p><ol><li><a href="https://developer.huawei.com/consumer/en/service/josp/agc/index.html">AppGallery Connect</a> giriş yapın. Şayet üyeliğin yoksa şu <a href="https://developer.huawei.com/consumer/en/doc/start/registration-and-verification-0000001053628148">linkteki</a> adımları izleyerek üyelik oluşturabilirsiniz.</li><li><a href="https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myProject">My Projects </a>den yeni bir proje oluşturun veya bir proje seçin.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vOO4SVX0nDlGH8mo6JHTdA.png" /><figcaption>Proje Listesi</figcaption></figure><p>3. “Project Setting” &gt; “General information” sekmesinde API key bilgisine erişebileceksiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VEsYbc_NUtxjq5pHovdQLQ.png" /><figcaption>AppGallery Project API Key</figcaption></figure><p>Resmi dokümana göre, API anahtarı güvenliğini korumak için önlemler almanız tavsiye edilir. Oluşturulan keyin güvenliğini sağlamak için “<strong>Credentials” </strong>sekmesinden kısıtlamalar yapabilirsiniz. Bu işleme dair ayrıntılar için <a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/faq-0000001050166999#section78166185011">resmi dokümanı</a> inceleyebilirsiniz.</p><p><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/faq-0000001050166999#section78166185011">Document</a></p><h3><strong>Map Kit API Aktif Etme</strong></h3><ol><li>“Project Setting” &gt; “General information” sekmesinde arama alanına “map kit” yazıp arama yapın.</li><li>Arama sonucu gelen “Map Kit” aktif edin.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Swr-OJTF5n8dKISGlYV4Q.png" /></figure><h3>Haritayı Tanımlama</h3><p>Haritayı kullanmak için örneğin “map” isminde id değerinde içi boş bir div elemanı ekleyin. Sonrasında aşağıdaki kod örneğinde olduğu gibi HwMap objesini size uygun parametreleri kullanarak “map” id değerli div elemanı içinde haritanızı oluşturabilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/beee51752edd5b31a7f639815c7fff7b/href">https://medium.com/media/beee51752edd5b31a7f639815c7fff7b/href</a></iframe><p>Haritaya ait daha fazla özellik veya farklı harita tanımlamaları için <a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/javascript-api-basic-map-0000001064621312">resmi dokümanı</a> inceleyebilirsiniz.</p><p><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/javascript-api-basic-map-0000001064621312">Document</a></p><h3>Haritaya İşaretçi(Marker) Ekleme</h3><p>Haritada belirli bir alanı göstermek için marker özelliğini kullanabilirsiniz. Bunun için aşağıdaki kod örneğini yazabilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48d9efa3c101fb4ef7545996bc68e20f/href">https://medium.com/media/48d9efa3c101fb4ef7545996bc68e20f/href</a></iframe><p>Farklı marker özellikleri için <a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/javascript-api-drawing-on-map-0000001050162118">resmi dokümanı</a> inceleyebilirsiniz.</p><p><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/javascript-api-drawing-on-map-0000001050162118">Document</a></p><p>Ayrıca marker ekleme kod örneğinde olduğu gibi marker tıklama özelliği ekleyebiliyoruz. Bu sayede marker tıklanması ile kod örneğindeki gibi siteden Petal Maps harita yönlendirmesi yapabilir ve “navigate” özelliği ile kullanıcıya, kullanıcı konumundan(şayet kullanıcı konum erişimine izin verdi ise) hedef noktaya(marker konumuna) rota çizdirebiliriz. Burada aynı şekilde Google Haritalara veya başka bir harita uygulamasına da yönlendirme yapabilirisiniz. Petal Maps Navigationa ait diğer parametreler için <a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/petal-maps-application-navigation-0000001060038018">resmi dokümanı</a> inceleyebilirsiniz.</p><p><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/petal-maps-application-navigation-0000001060038018">Document</a></p><h3>Çıktı</h3><p>Yukarıda parça parça verdiğim kodları bir bütün haline getirdiğimizde aşağıda yer alan gist dokümanında olduğu gibi bir kod elde ederiz. Ayrıca tarayıcı üzerinden görünümü ise aşağıda yer alan görseldeki gibi olmaktadır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*4LyIBprfT_G4SwIACn0Gpg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9208995025438e61749bf8ad58049f8/href">https://medium.com/media/f9208995025438e61749bf8ad58049f8/href</a></iframe><h3>Sonuç</h3><p>Gördüğünüz üzere Huawei Map kullanarak web sitenizde harita kullanımı, haritada belirli bir veya birden fazla yer gösterimi oldukça basit ve maliyet açısından oldukça uygun olmakta. Bu yazıda değindiğim özelliklerden haricen farklı birçok harita çeşidi ve özellikleri de bulunmaktadır. Bunlardan uygun olanı kendi projenizde kullanabilirsiniz.</p><p>İyi kodlamalar…</p><h3>Referanslar</h3><ul><li><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/javascript-api-introduction-0000001050164063">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-References/js-hwmap-0000001050990165">Document</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a6de8e659e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding a Huawei Map with a Marker to Your Website]]></title>
            <link>https://medium.com/@nabiguzel/adding-a-huawei-map-with-a-marker-to-your-website-fddf2f42660c?source=rss-12f126b4bcc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fddf2f42660c</guid>
            <category><![CDATA[website]]></category>
            <category><![CDATA[map-marker]]></category>
            <category><![CDATA[huawei-map]]></category>
            <category><![CDATA[petal-maps]]></category>
            <category><![CDATA[navigation]]></category>
            <dc:creator><![CDATA[Nabi Güzel]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 16:53:44 GMT</pubDate>
            <atom:updated>2023-01-20T16:53:44.167Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn how to use the Huawei MapKit API to enhance your web application with dynamic and interactive maps, including the ability to show markers, open Petal Maps by clicking on the marker, and draw routes from the user’s location to the clicked marker location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*HaHW8vNYTZVv-Ku2VUQJxQ.jpeg" /></figure><h3>Introduction</h3><p>Displaying maps on websites provides a great user experience in certain situations. In addition, being able to open a map application and create a route to the location shown by clicking on the location marker enhances this experience even further.</p><p>In this article, we will examine how to implement location display using Huawei MapKit, one of the best alternatives for displaying maps in web applications for free. We will also explore how to provide Petal Maps routing by clicking on the location marker and drawing a route from the user’s location to the location shown on the map.</p><h3>Pricing</h3><p>Huawei offers $300 per month to use all Petal Maps products, including map display. This way, you have the right to use the product for free up to the amount of the renewed limit each month. This limit is more than sufficient for basic usage. You can access detailed pricing information through the <a href="https://developer.petalmaps.com/price">link</a>.</p><p><a href="https://developer.petalmaps.com/price">HUAWEI Petal Maps Platform - HUAWEI Developer</a></p><h3>Obtaining the API Key</h3><p>To use the map service, you must first have an API key, you can follow the steps below.</p><ol><li>Sign in to <a href="https://developer.huawei.com/consumer/en/service/josp/agc/index.html">AppGallery Connect</a>. If you do not have an account, you can create one by following the steps in the <a href="https://developer.huawei.com/consumer/en/doc/start/registration-and-verification-0000001053628148">link</a>.</li><li>Create a new project from ‘<a href="https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myProject">My Projects</a>’ or select an existing project.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vOO4SVX0nDlGH8mo6JHTdA.png" /><figcaption>List of the projects</figcaption></figure><p>3. You can access the API key information in the “General information” tab under “Project Settings”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VEsYbc_NUtxjq5pHovdQLQ.png" /><figcaption>AppGallery Project API Key</figcaption></figure><p>According to the official document, you are advised to take measures for protecting the API key security. To ensure the security of the key created, you can make restrictions from the “Credentials” tab. You can review the <a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/faq-0000001050166999#section78166185011">official documentation</a> for details on this process.</p><p><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/faq-0000001050166999#section78166185011">Document</a></p><h3>Enabling the Map Kit API</h3><ol><li>“Project Setting” &gt; “General information” tab and search “map kit” in the search field.</li><li>Activate “Map Kit” from the search results.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Swr-OJTF5n8dKISGlYV4Q.png" /></figure><h3>Initializing the Map Kit API</h3><p>To use the map, add an empty div element with an id of “map” for example. Then, you can create your map in the “map” id element using the HwMap object with the appropriate parameters, as shown in the following code example.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/beee51752edd5b31a7f639815c7fff7b/href">https://medium.com/media/beee51752edd5b31a7f639815c7fff7b/href</a></iframe><p>You can refer to the <a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/javascript-api-basic-map-0000001064621312">official documentation</a> for additional properties or different map definitions for the map.</p><p><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/javascript-api-basic-map-0000001064621312">Document</a></p><h3>Adding Markers to the Map</h3><p>You can use the marker feature to show a specific area on the map. You can use the following code example for this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48d9efa3c101fb4ef7545996bc68e20f/href">https://medium.com/media/48d9efa3c101fb4ef7545996bc68e20f/href</a></iframe><p>You can refer to the <a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/javascript-api-drawing-on-map-0000001050162118">official documentation</a> for different marker properties.</p><p><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/javascript-api-drawing-on-map-0000001050162118">Document</a></p><p>Additionally, as in the marker adding code example, we can add the marker click feature. This way, when the marker is clicked, we can make a Petal Maps map redirect from the site, as in the code example, and with the “navigate” feature, we can draw a route for the user from their location (if the user has allowed location access) to the destination(marker location) point. Here, you can also redirect to Google Maps or another map application. You can refer to the <a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/petal-maps-application-navigation-0000001060038018">official documentation</a> for other parameters related to Petal Maps Navigation.</p><p><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/petal-maps-application-navigation-0000001060038018">Document</a></p><h3>Output</h3><p>When we put together the code snippets that I have provided piece by piece above, we get a code like the one in the gist document below. Also, the view on the browser is shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*4LyIBprfT_G4SwIACn0Gpg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9208995025438e61749bf8ad58049f8/href">https://medium.com/media/f9208995025438e61749bf8ad58049f8/href</a></iframe><h3>Conclusion</h3><p>Gördüğünüz üzere Huawei Map kullanarak web sitenizde harita kullanımı, haritada belirli bir veya birden fazla yer gösterimi oldukça basit ve maliyet açısından oldukça uygun olmakta. Bu yazıda değindiğim özelliklerden haricen farklı birçok harita çeşidi ve özellikleri de bulunmaktadır. Bunlardan uygun olanı kendi projenizde kullanabilirsiniz.</p><p>Good coding…</p><h3>References</h3><ul><li><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/javascript-api-introduction-0000001050164063">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-References/js-hwmap-0000001050990165">Document</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fddf2f42660c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FastAPI | Basit Hızlı Örnekle İnceleme]]></title>
            <link>https://medium.com/huawei-developers-tr/fastapi-basit-hizli-ornekle-inceleme-58ac0937531f?source=rss-12f126b4bcc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/58ac0937531f</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[swagger-ui]]></category>
            <dc:creator><![CDATA[Nabi Güzel]]></dc:creator>
            <pubDate>Fri, 01 Jul 2022 11:52:06 GMT</pubDate>
            <atom:updated>2022-07-01T11:52:06.212Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*du7p50wS_fIsaC_lR18qsg.png" /><figcaption><a href="https://fastapi.tiangolo.com/"><em>FastAPI framework, high performance, easy to learn, fast to code, ready for production</em></a></figcaption></figure><h3>Giriş</h3><p>Herkese merhaba,</p><p>Daha önce bir kaç yerde duyduğum FastAPI teknolojisi kısa bir süre önce temelde inceleyip basit bir örnek oluşturma fırsatım oldu. Bu makalemde çalışma sürecinde tuttuğum notlarımı, birinin işine yarar düşüncesi ile derleyip paylaşıyorum.</p><h3>Nedir bu FastAPI?</h3><p>FastAPI bir RestAPI geliştirme aracıdır. Kendilerinin deyimi ile “FastAPI kütüphanesi, yüksek performans, öğrenmesi kolay, kodlaması hızlı, üretime hazır” bir kütüphanedir.</p><p><a href="https://fastapi.tiangolo.com/">FastAPI - FastAPI</a></p><h3>Nasıl yüklerim? (Setup)</h3><p>FastAPI yüklemek için öncelikle bilgisayarınızda “pip -V”<em> </em>komutunun bir karşılığı olmak zorunda. Yüklemek için ise doküman sitesi olan <em>“</em><a href="https://pip.pypa.io/en/stable/installation"><em>pip.pypa.io</em></a><em>”</em> yer alan adımları izleyebilirsiniz.</p><p><a href="https://pip.pypa.io/en/stable/">pip documentation v26.0.1</a></p><p>“pip” yükleme işlemi tamamlandıktan sonra FastAPI yüklemesi için çalıştırmanız gereken komut:</p><pre>pip install fastapi</pre><p>Ayrıca localde bir sunucuya ihtiyacınız olacak. Bunun için çalıştırmanız gereken komut:</p><pre>pip install &quot;uvicorn[standart]&quot;</pre><h4>Proje Oluşturma ve Çalıştırma</h4><p>Yüklemeler bittikten sonra bir proje klasörü açıp içinde bir tane “main.py” dosyası oluşturalım. (Bu çalışma için oluşturduğum “main.py” dosyasına ait gisti, kodları bir bütün halinde içerir şekilde makale sonunda paylaştım.)</p><p>Dosya oluşturduktan sonra geliştirmeye sürecinde yapacağımız değişiklikleri bize anlık olarak test imkanı sunan bir sunucu çalıştırmak gerekiyor. Anlık değişiklikleri algılayan bir sunucu için çalıştırmanız gereken komut:</p><pre>uvicorn main:app --reload</pre><h4>Proje Yapısı</h4><p>Ben bu projede temelde sadece bir dosya üzerinden geliştirme yapıyorum, amacım en temelde birer GET, POST, PUT, DELETE istekleri oluşturmak, bunun için ise klasik “Todo” uygulamasını ele aldım.</p><p>İsteğe bağlı olarak bu klasör altında ilerleyişe göre hiyerarşik bir dosya yapısı kurulabilir. Örneğin “routers” isminde oluşturulacak bir klasör altında farklı dosyalarda “routing” kümelemesi oluşturulabilir.</p><h4>Hello World, nasıl yazarım?</h4><p>“Hello World” öğrenmeye yeni başlanan bir dilin veya teknolojinin öncelikli ilk kodlamasıdır. :) Bu amaçla oluşturduğum aşağıdaki kodda, en temelde bir GET isteği oluşturmuş oldum. Aynı zamanda FastAPI otomatik olarak Swagger arayüzüne sahip bir döküman sayfası oluşturmuş oldu.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3596d8373662985dbfb19a5ea67ad4ff/href">https://medium.com/media/3596d8373662985dbfb19a5ea67ad4ff/href</a></iframe><p>Swagger dosyasını, komut ekranında (cmd, terminal) sunucu başlatıldıktan sonra yazan local çalışma linkini, taratıcıdan sonuna “/docs” ekleyerek açabiliriz. Örneğin:</p><blockquote><a href="http://127.0.0.1:8000/docs">http://127.0.0.1:8000/docs</a></blockquote><h4>Dokümantasyon için Swagger özelliklerini nasıl uygularım?</h4><p>Yukarıdaki örnekte yazan fonksiyon ismi “camelCase” olursa, dokümanda aşağıda görüldüğü üzere “Saygreeting” gibi yazar, ama “say_greeting” şeklinde yazsaydık “Say Greeting” yazacaktı.</p><p>Fonksiyon isimlerini belirttiğime bağlı kalarak yazmak yerine, istediğimiz gibi yazıp, aşağıda yazıldığı gibi istek türünü yazdığımız yerde de, ikinci bir parametre olarak, FastAPI OpenAPI 3.0 uyumlu olduğu için, “<strong>summary</strong>” parametresini kullanarak da yazabiliriz.</p><pre>@app.get(&quot;/&quot;, summary=&quot;Say Greeting&quot;)</pre><p>Kullanılabilecek diğer parametreler için <a href="https://swagger.io/docs/">Swagger dokümanını</a> gözden geçirebilirsiniz.</p><p><a href="https://swagger.io/docs/">Swagger Documentation</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*89WDt9dyU8COkr535HICzg.png" /><figcaption><a href="http://127.0.0.1:8000/docs">http://127.0.0.1:8000/docs</a></figcaption></figure><h3>CRUD nasıl yazarım?</h3><p>Ben bu çalışmada şimdilik herhangi bir veritabanı kullanmadan, boş bir dizi oluşturup onun içine ekleme, listeleme, güncelleme ve silme komutlarını gerçekleştirecek istekleri yazdım.</p><h4>İstek türünü(GET, POST, PUT, DEL) nasıl tanımlarım?</h4><p>Öncelikle istek türünü, ilgili işlemi yapacak fonksiyonun üzerinde yazılan kısım belirlemekte. Yukarıdaki örnekte olduğu gibi “@app.get(“/”) hemen altında yazan fonksiyona GET isteği ile erişilebileceğini belirtmiştir.</p><p>“id” gibi “query” değişken parametreleri ise süslü parantez içinde yazmanız yeterli olacaktır.</p><p>Ben yazdığım istekleri swagger dokümanında “todo” altında gruplandırabilmek için, aşağıdaki görselde yer aldığı gibi, istek türüne “tags” parametresini ekleyip içine “Todo” eklemem yeterli oldu.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f76c1d0dd682357e468261ab6d719a4d/href">https://medium.com/media/f76c1d0dd682357e468261ab6d719a4d/href</a></iframe><h4>Parametreleri(path, query, body) nasıl belirlerim?</h4><p>Fonksiyona gelecek parametre türünün “Path” mi yoksa “Query” mi olacağını fonksiyon parametresi olarak belirleyebiliriz, yukarıdaki örnekte “getTodoDetail” fonksiyonda “Path” kullanımında olduğu gibi. Ayrıca parametrenin yanında görünmesini istediğiniz notu, “Query” veya “Path” içinde “description” parameresini kullanarak yazabilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*paPPT3Isgj7G6WU2qThpWA.png" /><figcaption>“getToDetail” fonksiyonu parametre “description” metin gösterimi</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e09b4e6abe5688af579ce929c75da21/href">https://medium.com/media/4e09b4e6abe5688af579ce929c75da21/href</a></iframe><h4>Validasyonları nasıl belirlerim?</h4><p>“Post”, “Patch”, “Put” gibi isteklerde, isteğin “body” elemanı olarak gelecek objenin ne olacağını parametre içinde ilgili obje tip ataması ile belirleyebiliyoruz. Ayrıca bu belirleme otomatik validasyonu da aktif etmektedir. Örneğin gerçekleştireceğim bir “post” isteği şayet “body” içinde 20 karakterden uzun bir değeri olan “title” parametresine sahip ise, “title” değeri maksimum 20 karakter olabildiği için sistem otomatik olarak bana aşağıdaki görselde yer alan hatayı döndürmekte.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*d1Eps5sdMhfdlzbanWruyw.png" /></figure><p>Dönüş tipini doğrudan yazacağınız “JSON” yapısı ile belirleyebildiğimiz gibi ayrıca yukarıdaki “get” kod görselinde yer alan “JSONResponse” kullanımı ile dönüşün “status” değerini de belirleyebilmekteyiz.</p><p>Her ne kadar FastAPI ile değil de “<em>python</em>” ile ilgili olmasına rağmen not olarak kalması açısından yazıyorum; “getTodoDetail” fonksiyonunda yazan <strong><em>“… next(filter(lambda…”</em></strong> ile başlayan kısımda “next” ifadesi sayesinde filtreleme sonucunda tek bir eleman dönmektedir. Şayet dizi olarak, yani liste halinde dönmesini istediğimde “getTodoList” fonksiyonunda olduğu gibi “list” ifadesini <strong><em>“ … list(filter(lambda…”</em></strong> olduğu gibi yazmam gerekiyordu.</p><h4>Modelleri nasıl yazarım?</h4><p>Kullanılacak istekte kısıtlamaları model üzerinde yapılmakta olup ilgili isteğe özel model yazmak gerekiyor.</p><p>Örneğin “Update” modelini BaseModel olarak ele aldım çünkü burada yer alacak tüm parametreler güncellemede opsiyonel olarak gelmekte. Yani kullanıcı sadece zorunlu alan olmayan bir parametre olan “tags” üzerinde güncelleme yapmak isteyebilir. Ayrıca “id” değerini Update modelinde yazmadım çünkü kullanıcı bu parametreye güncellemede erişememesi gerekiyor. “Create” için oluşturduğum model parametrelerine dikkat ederseniz, onların opsiyonel olma durumlarını kaldırdım, böylelikle kullanıcı o parametreleri göndermek zorunda kalıyor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b912fef74a67825b1e19d42bb65668a/href">https://medium.com/media/0b912fef74a67825b1e19d42bb65668a/href</a></iframe><h3>Çıktı</h3><p>Yukarıda parça parça verdiğim kodları bir bütün haline getirdiğimizde aşağıda yer alan gist dökümanında olduğu gibi bir kod elde ederiz. Ayrıca bu kodu çalıştırdığımızda tarayıcıdan da aşağıdaki Swagger dokümanı arayüzüne erişim sağlayabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PF84szAz3XR2WDvOE3JlBg.png" /><figcaption>“main.py” dosyası Swagger doküman çıktısı</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efd6eceafa8b2035c49d9913e9291825/href">https://medium.com/media/efd6eceafa8b2035c49d9913e9291825/href</a></iframe><h3>Sonuç</h3><p>Gördüğünüz üzere FastAPI ile servis istekleri oluşturmak oldukça basit. Bu aşamadan sonra kendi mantıksal işlemlerimizi içeren kodlamaların eklenmesi ile daha kullanışlı bir projenin hızlı bir şekilde üretilmesi mümkündür. Örneğin; bir veritabanı entegrasyonu ekleyip o veri tabanı üzerinde işlemleri yapacak kodları kolaylıkla ekleyebiliriz.</p><p>İyi kodlamalar…</p><h3>Referanslar</h3><ul><li><a href="https://fastapi.tiangolo.com/">FastAPI - FastAPI</a></li><li><a href="https://pip.pypa.io/en/stable/">pip documentation v26.0.1</a></li><li><a href="https://github.com/liannewriting/YouTube-videos-public/tree/main/fastapi-python-tutorial-intro">YouTube-videos-public/fastapi-python-tutorial-intro at main · liannewriting/YouTube-videos-public</a></li><li><a href="https://swagger.io/docs/">Swagger Documentation</a></li><li><a href="https://www.geeksforgeeks.org/lambda-filter-python-examples/">Lambda and filter in Python Examples - GeeksforGeeks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58ac0937531f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers-tr/fastapi-basit-hizli-ornekle-inceleme-58ac0937531f">FastAPI | Basit Hızlı Örnekle İnceleme</a> was originally published in <a href="https://medium.com/huawei-developers-tr">Huawei Developers - Türkiye</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Node.js, Express.js | İleri Seviye E-Posta Gönderim Konseptleri]]></title>
            <link>https://medium.com/huawei-developers-tr/node-js-express-js-ileri-seviye-e-posta-gonderim-konseptleri-6c7e33ba640b?source=rss-12f126b4bcc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c7e33ba640b</guid>
            <category><![CDATA[handlebars]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nodemailer]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[i18n]]></category>
            <dc:creator><![CDATA[Nabi Güzel]]></dc:creator>
            <pubDate>Fri, 01 Jul 2022 11:31:49 GMT</pubDate>
            <atom:updated>2022-07-01T11:31:49.934Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJS_YEmbCO6hQfuy3tdhFg.png" /></figure><h3>Giriş</h3><p>Herkese merhaba,</p><p>Sunucu tarafında, kullanıcıya bazı mailler göndeririz. Bu maillere; şifre unutulması durumunda iletilen bir kod veya erişim linki içeren mail, şifre değişimi sonrası kullanıcı uyarı maili, kullanıcıya bir bülten iletimi gibi durumları örnek verebiliriz.</p><p>Bu yazıda, Node.js ve Express.js ile geliştirilmiş bir uygulamada, uygulama kullanıcılarına şablon tasarımları kullanılarak, kullanıcının diline uygun metinlerle mail gönderiminin nasıl yapıldığını inceleyeceğiz.</p><h3>Kullanacağımız Teknolojiler</h3><p>Projede temelde 3 kütüphane kullanacağız. Bunlar:</p><ul><li>i18n</li><li>nodemailer</li><li>nodemailer-express-handlebars</li></ul><h4>i18n ile çoklu dil kullanımı</h4><p>Sunucu taraflı geliştirmelerde kullanıcıya belli başlı mesajları, kullanıcının diline uygun bir dil çevirisi ile sonuç döndürmek gerekmektedir. Bunun için kullanılan en yaygın kütüphane “i18n” kütüphanesidir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*ADnVYpo-lvKmXvHcTHA3fA.png" /></figure><p><a href="https://www.npmjs.com/package/i18n">i18n</a></p><p>i18n kullanımında, desteklemeyi düşündüğümüz her dile özel yazılmış “json” uzantılı dosyalar oluştururuz. Bu dosyalarda ortak anahtar kelimeler(veya cümleler) ve anahtar kelimenin(cümlenin) o dilde karşılığı yazılır. Burada daha fazla ayrıntıya girmeden ilgili dokümanı ve bu konu hakkında yazılmış makalelere bakmanızı öneririm.</p><h4>Nodemailer ile e-posta gönderimi</h4><p>Maillerin gönderimi için node.js de kullanılan en yaygın kütüphanelerden biri “nodemailer” kütüphanesidir.</p><p><a href="https://nodemailer.com/about/">Nodemailer</a></p><p>Nodemailer yapılandırması, kullanılan e-posta hizmetine göre değişkenlik gösterir. Örnek yapılandırma için aşağıda, resmi sitesinden alıntı yaptığım örneğe bakabilirsiniz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82aafd3be8c394ee2c7b44046d7b0169/href">https://medium.com/media/82aafd3be8c394ee2c7b44046d7b0169/href</a></iframe><h4>Handlebar ile semantik şablon oluşturma</h4><p>Handlebar basit bir şablonlama dilidir. Handlebar, geliştirdiğimiz web sitesini parçalara ayırmamıza ve parametrikleri kullanarak yönetmemize olanak tanır.</p><p>Örneğin; üzerinde çalıştığımız web sitesi için tasarımın alt kısmını (footer) ve üst kısmını (header) ve ortaya gelecek farklı parametre ve tasarımlara sahip gövde (body) kısımlarını parçalar haline getirip, bunları belli bir yapıda ana yerleşim (main layout) içinde parametrik olarak birleştirip bir web sitesi elde edebiliriz.</p><p>Detaylı bilgi için aşağıda verdiğim resmi dokümana bakabilirsiniz.</p><p><a href="https://handlebarsjs.com/">Handlebars</a></p><h4>express-handlebars nedir?</h4><p>Bu kütüphane, Express içinde Handlebars kullanımı için geliştirilmiş ve tam yığın (fullstack) bir web sayfası yazmamıza imkan sunan bir kütüphanedir. Bu kütüphane sayesinde hangi sayfanın ana kalıp sayfası olduğu, hangi sayfaların parçalı dosyalar olduğu gibi bir yapıyı kurabiliyoruz. Ayrıca görüntüleme sayfası içinde kullanılacak fonksiyonları da belirleyebiliyoruz.</p><p>Aşağıda verdiğim örnekte “engine” içinde yazılan parametreler sayesinde yukarıda belirlediğim yapıyı kurabildim. Yapı kurulduktan sonra ise yazdığım örnek kullanımda, görüntülemek istediğim sayfanın “contactForm” sayfası olduğunu ve bu sayfanın “main” ismindeki ana yerleşim sayfası içinde gösterilmesini istiyorum.</p><p>Örnekte yer alan “path.render” fonksiyon kullanımında ilk parametreden sonra göndereceğimiz herhangi bir parametre veya nesnenin, “contactForm” parametresinde olduğu gibi, sayfa içinde bir değişken olarak kullanabileceğini belirtebiliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4b9ddba5291efe9fc0885bcf8e4dfa5/href">https://medium.com/media/c4b9ddba5291efe9fc0885bcf8e4dfa5/href</a></iframe><p>Her ne kadar bu makale için konu dışı olsa da “express-handlebars” kullanımını “nodemailer-express-handlebars” kullanımının daha iyi anlaşılır olması için verdim.</p><p>Ayrıca geliştirme sürecinde, yaptığımız her değişiklikte, tasarladığımız sayfaları görüntüleyip kontrol etmek ve test etmek için mail göndermek yerine, sadece geliştirme modu için tarayıcıda harici bir sayfa olarak görüntülemek için “express-handlebars” kullanabiliriz. Bu da, hızlı geliştirme yapmamızı sağlar.</p><h4>Neden nodemailer-express-handlebars?</h4><p>Biz bu projede “<a href="https://github.com/ericf/express-handlebars">express-handlebars</a>” üzerinden geliştirilmiş, “nodemailer” için tasarlanmış “nodemailer-express-handlebars” kütüphanesini kullanacağız.</p><p>Yukarıda yer alan “Nodemailer ile mail gönderimi” örneğinden farklı olarak aşağıda yer alan örnekte “sendMail” fonksiyonu öncesinde “compile” olarak “nodemailer-express-handlebars” kullanması gerektiğini belirtiyoruz.</p><p>Aşağıdaki örnekte yer alan “hbs(opitons)” da yer alan “options” parametresi ise yukarıda yer alan “Express handlebars kullanımı” örneğinde yer alan “engine” fonksiyonu parametreleri yapı ve kullanım amacı ile birer bir aynıdır.</p><p>Aşağıdaki örnekte dikkat edilmesi gereken kısım ise “sendMail” fonksiyonundaki “text” ve “html” parametreleri yerine, mailin iletilmeden önce hangi sayfa ile derlenip iletileceğini “template” ile, bu sayfa içinde kullanılacak parametrelerin neler olduğunu da “context” ile belirliyoruz.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c117172a443f05433a43eefdc272786e/href">https://medium.com/media/c117172a443f05433a43eefdc272786e/href</a></iframe><h4>Handlebars içinde i18n kullanımı</h4><p>Öncelikle projeye i18n yükleyip, gerekli konfigürasyon ayalarını yapmak gerekiyor. Sonrasında,“Nodemailer Express Handlebars kullanımı” örneğinde olduğu gibi, “helpers” içinde i18n den türettiğiniz bir “translate” fonksiyonunu görüntüleme sayfasına parametre olarak iletiriz. Artık bu sayede mail için tasarladığımız sayfalarda bu fonksiyonu kullanarak sayfa içinde yer alan metinleri, isteği gerçekleştiren kullanıcının diline uygun olarak çevirip, malin iletilmesini sağlamış oluruz.</p><p>Aşağıda örneğini yazdığım kodda “translate” ile başlayanların tümü yukarıdaki tanımlamada “helpers” içinde tanımladığım fonksiyonlardır. “Helpers” fonksiyonlarında ilk parametreden sonraki parametreler bir bütün olarak iletilir. Bu nedenle birden fazla parametre kullanılması gereken metin çevirileri için yazdığım “translateByHash” ismindeki fonksiyonu kullanırız. Ayrı bir kullanım olarak, tek bir parametre için, “%s” kullanarak şu örnekteki gibi de yazılabiliriz:</p><pre>{{translate “Dear %s” userName}}</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c7b6b15a1f21b7c9056dc796d6e640a/href">https://medium.com/media/2c7b6b15a1f21b7c9056dc796d6e640a/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*6wu0tB1CZc7B4FFMdRgHJA.png" /><figcaption>Tasarlanan mail</figcaption></figure><h4>Örnek proje kodlaması</h4><p>Yukarıda verdiğim kod parçalarını, derleyip daha düzgün hale getirdiğim proje dosyasına aşağıdaki GitHub linkinden erişebilirsiniz.</p><p><a href="https://github.com/nabiguzel/designed-email-sender">GitHub - nabiguzel/designed-email-sender: Designed and Localized Email Sender</a></p><h3>Sonuç</h3><p>Geliştirdiğimiz bu yapı sayesinde kullanıcılara iletilen sisteme ait maillerin yapı ve kodlama olarak dosyalanıp daha düzgün takibi ve kodlamasını ve görünüm olarak tasarımının daha iyi olmasını ayrıca içerdiği metinlerin dil değişkenli olmasını sağlamış olduk.</p><p>İyi kodlamalar…</p><h3>Referanslar</h3><ul><li><a href="http://www.umutozel.com/handlebars-js">Yeni Başlayanlar için Handlebars.js</a></li><li><a href="https://waelyasmina.medium.com/a-guide-into-using-handlebars-with-your-express-js-application-22b944443b65">A Step By Step Guide To Using Handlebars With Your Node js Application</a></li><li><a href="https://medium.com/jsblend/how-to-send-emails-with-templates-using-nodejs-176b72c1406d">How to Send Emails With Templates using NodeJs</a></li><li><a href="https://www.npmjs.com/package/i18n">i18n</a></li><li><a href="https://nodemailer.com/about/">Nodemailer</a></li><li><a href="https://handlebarsjs.com/">Handlebars</a></li><li><a href="https://github.com/ericf/express-handlebars">GitHub - ericf/express-handlebars: A Handlebars view engine for Express which doesn&#39;t suck.</a></li><li><a href="https://github.com/yads/nodemailer-express-handlebars">GitHub - yads/nodemailer-express-handlebars: A plugin for nodemailer that uses express-handlebars view engine to generate emails</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c7e33ba640b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers-tr/node-js-express-js-ileri-seviye-e-posta-gonderim-konseptleri-6c7e33ba640b">Node.js, Express.js | İleri Seviye E-Posta Gönderim Konseptleri</a> was originally published in <a href="https://medium.com/huawei-developers-tr">Huawei Developers - Türkiye</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[‍FastAPI | Review with a fast simple example]]></title>
            <link>https://medium.com/huawei-developers/fastapi-review-with-a-fast-simple-example-2120032e1ff1?source=rss-12f126b4bcc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2120032e1ff1</guid>
            <category><![CDATA[swagger-ui]]></category>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Nabi Güzel]]></dc:creator>
            <pubDate>Fri, 01 Jul 2022 07:00:25 GMT</pubDate>
            <atom:updated>2022-07-01T11:46:57.643Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*du7p50wS_fIsaC_lR18qsg.png" /><figcaption><a href="https://fastapi.tiangolo.com/"><em>FastAPI framework, high performance, easy to learn, fast to code, ready for production</em></a></figcaption></figure><h3>Introduction</h3><p>Hi everyone,</p><p>I’ve heard of FastAPI framework technology in a few places before, I recently had the opportunity to examine it basically and create a simple example. In this article, I compile and share the notes that I took during the working process with the thought that they will be useful for someone.</p><h3>What is this FastAPI?</h3><p>In their own words, this is a library that “FastAPI framework, high performance, easy to learn, fast to code, ready for production.”.</p><p><a href="https://fastapi.tiangolo.com/">FastAPI - FastAPI</a></p><h3>How can I set up FastAPI?</h3><p>To install FastAPI, you must first have an equivalent of the “pip -V” command on your computer. To install it, you can follow the steps on the documentation site at “pip.pypa.io”.</p><p><a href="https://pip.pypa.io/en/stable/">pip documentation v26.0.1</a></p><p>After the “pip” installation is complete, the command you need to run to install FastAPI is :</p><pre>pip install fastapi</pre><p>You will also need a local server. The command you need to run for installation of the local server is:</p><pre>pip install &quot;uvicorn[standart]&quot;</pre><h4>Creating and Running a Project</h4><p>After the installations are completed, let’s open a project folder and create a “main.py” file in it. (At the end of the article, I shared the gist of the “main.py” file I created for this study, containing the codes as a whole.)</p><p>After creating the file, we need to run a server that allows us to instantly test the changes we will make during the development process. Here’s the command you should run for a server that detects instant changes:</p><pre>uvicorn main:app --reload</pre><h4>Project Structure</h4><p>In this project, I only develop from a single file. I aim to create basically GET, POST, PUT, and DELETE requests, so I have handled the classic “Todo” application.</p><p>Optionally, a file hierarchy structure could create under this folder according to its progress. For example, “routing” clustering can be created in different files under a folder named “routers”.</p><h4>How do I write Hello World?</h4><p>“Hello World” is the first coding test for a new language or technology to learn. :) In the code below I created for this purpose, I basically created a GET request. At the same time, FastAPI automatically created a document page with a Swagger interface.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3596d8373662985dbfb19a5ea67ad4ff/href">https://medium.com/media/3596d8373662985dbfb19a5ea67ad4ff/href</a></iframe><p>We can open the swagger file by adding “/docs” to the end of the local working link, which is written on the command screen (cmd, terminal) after the server starts. For example:</p><blockquote><a href="http://127.0.0.1:8000/docs">http://127.0.0.1:8000/docs</a></blockquote><h4>How can I implement Swagger features for the documentation?</h4><p>If the function name in the above example is “camelCase”, it would read “Saygreeting” as seen below in the document, but if I had written it as “say_greeting”, it would have written, “Say Greeting”.</p><p>Instead of writing the function names according to what I have specified above, we can write them as we want. For this, we can use the “summary” parameter as a second parameter where we write the request type as the below example since FastAPI is an OpenAPI 3.0 compatible.</p><pre>@app.get(&quot;/&quot;, summary=&quot;Say Greeting&quot;)</pre><p>You can review the <a href="https://swagger.io/docs/">Swagger documentation</a> for other parameters that can be used.</p><p><a href="https://swagger.io/docs/">Swagger Documentation</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*89WDt9dyU8COkr535HICzg.png" /><figcaption><a href="http://127.0.0.1:8000/docs">http://127.0.0.1:8000/docs</a></figcaption></figure><h3>How do I write CRUD?</h3><p>In this study, I have written requests that will create an empty array and perform the commands for adding, listing, updating, and deleting without using any database for now.</p><h4><strong>How do I determine the request type (GET, POST, PUT, DEL)?</strong></h4><p>First of all, the type of request is determined by the part written on the function that will perform the relevant operation. As in the example above, we can understand that the function written just below the “<a href="http://twitter.com/app">@app</a>.get(“/”) can be accessed with a GET request.</p><p>For “query” variable parameters such as “id”, it will be sufficient to write them in curly brackets.</p><p>In addition, we can use the “tags” parameter to group the requests we write in the swagger document. For example, in order to group the requests under “todo”, it was enough to add the “tags” parameter to the request type and add “Todo” to the request type, as shown in the image below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f76c1d0dd682357e468261ab6d719a4d/href">https://medium.com/media/f76c1d0dd682357e468261ab6d719a4d/href</a></iframe><h4>How can I define parameters (path, query, body)?</h4><p>We can specify whether the type of parameter that will come to the function is “Path” or “Query” as a function parameter, as in the use of “Path” in the “getTodoDetail” function in the example above. You can also write the note you want to appear next to the parameter using the “description” parameter in “Query” or “Path”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*paPPT3Isgj7G6WU2qThpWA.png" /><figcaption>Description text representation of “getToDetail” function with using the parameter “description”</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e09b4e6abe5688af579ce929c75da21/href">https://medium.com/media/4e09b4e6abe5688af579ce929c75da21/href</a></iframe><h4>How can I set the validations?</h4><p>In requests such as “Post”, “Patch”, and “Put”, we can determine what the object type that will come as the “body” element of the request will be, by assigning the relevant object in the parameter. In addition, this determination activates automatic validation. For example, when I run a post request that contains a “title” element value with longer than 20 characters in the body, the system automatically returned the following error to me, because the “title” has a maximum limit of 20 characters limitation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*d1Eps5sdMhfdlzbanWruyw.png" /></figure><p>We can determine the return type with the “JSON” structure by writing directly, or we can also determine the “status” value of the return by using the “JSONResponse” in the “get” code image above.</p><p>Although it is about “python”, not FastAPI, I write this as a note; In the part that starts with “… next(filter(lambda…”) written in the “getTodoDetail” function, a single element is returned as a result of the filtering, by using “next” statement. When I wish that it returns as a list, I must write the expression “list” as in the “getTodoList” function, as in “… list(filter(lambda…”).</p><h4>How can I write models?</h4><p>Restrictions on the request to be used are made on the model, and it is necessary to write a special model for the relevant request.</p><p>For example, I set the “Update” model as a BaseModel because all the parameters to be included here are optional in the update. So the user may only want to update on the non-mandatory parameter “tags”. Also, I didn’t write the “id” value in the Update model because the user should not be able to access this parameter in the update. If you pay attention to the model parameters I created for “Create”, I removed their optional status, so the user has to send those parameters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b912fef74a67825b1e19d42bb65668a/href">https://medium.com/media/0b912fef74a67825b1e19d42bb65668a/href</a></iframe><h3>Output</h3><p>When we combine the codes I gave above piece by piece, we get a code like a gist document below. In addition, when we run this code, we can access the following Swagger document interface from the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PF84szAz3XR2WDvOE3JlBg.png" /><figcaption>The document output of “main.py”</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efd6eceafa8b2035c49d9913e9291825/href">https://medium.com/media/efd6eceafa8b2035c49d9913e9291825/href</a></iframe><h3>Conclusion</h3><p>As you can see, creating service requests with FastAPI is quite simple. After this stage, it is possible to produce a more useful project quickly by adding the coding that includes our own logical operations. For example; We can add a database integration and easily add codes that will perform processes on that database.</p><p>Good coding…</p><h3>References</h3><ul><li><a href="https://fastapi.tiangolo.com/">FastAPI - FastAPI</a></li><li><a href="https://pip.pypa.io/en/stable/">pip documentation v26.0.1</a></li><li><a href="https://github.com/liannewriting/YouTube-videos-public/tree/main/fastapi-python-tutorial-intro">YouTube-videos-public/fastapi-python-tutorial-intro at main · liannewriting/YouTube-videos-public</a></li><li><a href="https://swagger.io/docs/">Swagger Documentation</a></li><li><a href="https://www.geeksforgeeks.org/lambda-filter-python-examples/">Lambda and filter in Python Examples - GeeksforGeeks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2120032e1ff1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/fastapi-review-with-a-fast-simple-example-2120032e1ff1">👨🏼‍💻FastAPI | Review with a fast simple example</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[‍Node.js, Express.js | Send Localized Emails With Templates]]></title>
            <link>https://medium.com/huawei-developers/node-js-express-js-send-localized-emails-with-templates-efa574211c78?source=rss-12f126b4bcc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/efa574211c78</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[i18n]]></category>
            <category><![CDATA[nodemailer]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[handlebars]]></category>
            <dc:creator><![CDATA[Nabi Güzel]]></dc:creator>
            <pubDate>Fri, 01 Jul 2022 05:45:59 GMT</pubDate>
            <atom:updated>2022-07-01T11:36:15.296Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJS_YEmbCO6hQfuy3tdhFg.png" /></figure><h3>Introduction</h3><p>Hello everyone,</p><p>On the server-side, we send some emails to the user. For example; an e-mail containing a code or an access link sent in case of forgetting a password, a user warning e-mail after a password change, and a newsletter delivery to the user.</p><p>In this article, we will examine how to send email to application users with texts suitable for the language of the user, using template designs, in an application developed with Node.js and Express.js.</p><h3>Technologies We Will Use</h3><p>We will basically use 3 libraries in the project:</p><ul><li>i18n</li><li>nodemailer</li><li>nodemailer-express-handlebars</li></ul><h4>Creation Multilingual use with i18n</h4><p>In server-side developments, it is necessary to return certain messages to the user with a language translation suitable for the user’s language. The most common library used for this is the “i18n” library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*ADnVYpo-lvKmXvHcTHA3fA.png" /></figure><p><a href="https://www.npmjs.com/package/i18n">i18n</a></p><p>In the use of this library, we create “json” files specially written for each language we intend to support. In these files, common keywords|phrases and the equivalent of the keyword|word in that language are written. Here, I suggest you look at the relevant document and the articles written on this subject, without going into more detail.</p><h4>Sending emails with Nodemailer</h4><p>One of the most common library used in node.js for sending emails is the “nodemailer” library.</p><p><a href="https://nodemailer.com/about/">Nodemailer</a></p><p>Nodemailer configuration varies depending on the email service used. For the example configuration, you can refer to the example I quoted from its official site below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82aafd3be8c394ee2c7b44046d7b0169/href">https://medium.com/media/82aafd3be8c394ee2c7b44046d7b0169/href</a></iframe><h4>Creating a semantic template with a Handlebar</h4><p>The handlebar is a simple templating language. Handlebar allows us to divide the website we developed into parts and manage it with ability to use parametric.</p><p>For example; for the website we are working on, we make the bottom part (footer) and top part (header) and body parts with different parameters and designs to come into pieces, and combine them parametrically in the main layout in a certain structure and create a web site. we can get the site.</p><p>For detailed information, you can refer to the official document that I give below.</p><p><a href="https://handlebarsjs.com/">Handlebars</a></p><h4>What is express-handlebars?</h4><p>This library is a library developed for the use of Handlebars in Express and allows us to write a full-stack web page. Thanks to this library, we can establish a structure such as which page is the main page as layout and which pages are partial pages. We can also specify the functions to be used within the displaying pages.</p><p>In the following example, I was able to set up the structure that I specified above, by writing the parameters in “engine”. After creating the structure, I want to display the “contactForm” page using the “main” page as the layout.</p><p>In the “path.render” function in the example, we can specify that any parameter or object that we send after the first parameter can be used as a variable on the page, just like the “contactForm” parameter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4b9ddba5291efe9fc0885bcf8e4dfa5/href">https://medium.com/media/c4b9ddba5291efe9fc0885bcf8e4dfa5/href</a></iframe><p>Although it is off-topic for this article, I have given the use of “express-handlebars” for a better understanding of the use of “nodemailer-express-handlebars”.</p><p>In addition, instead of sending emails to view and check and test pages that we designed for each change, we can use “express-handlebars” to view them on the browser as an external page just for development mode. That allows us to fast development.</p><h4>Why nodemailer-express-handlebars?</h4><p>In this project, we will use the “nodemailer-express-handlebars” library developed over “express-handlebars” and designed for “nodemailer”.</p><p>Unlike the “Sending email with Nodemailer” example above, in the example below, we specify that “nodemailer-express-handlebars” should be used as “compile” before the “sendMail” function.</p><p>The “options” parameter in “hbs(opitons)” in the example below is the same as the “engine” function parameters in the “Using Express handlebars” example above, with their structure and purpose of use.</p><p>In the example below, you can see that instead of the “text” and “html” parameters in the “sendMail” function, we use the “template” parameter to set the which page will be compiled before sending the email, and we use the “context” parameter for which parameters to be used in this page.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c117172a443f05433a43eefdc272786e/href">https://medium.com/media/c117172a443f05433a43eefdc272786e/href</a></iframe><h4>Using i18n in Handlebars</h4><p>First of all, it is necessary to install i18n in the project and make the necessary configuration settings. Then, we define the “translate” function that we defined from i18n in “helpers” parameters to use in the display page, as in the “Using Nodemailer Express Handlebars” example. By using the “translate” function on the pages we design for email, we can translate the texts on the page in accordance with the language of the user before sending emails.</p><p>Ayrıca bir kullanım olarak, tek bir parametre için, şu örnekteki gibi de yazılabilir:</p><p>In the code I have written for example below, all the ones that start with “translate” are the functions I defined in the “helpers” in the definition above. In “Helpers” functions, the parameters after the first parameter are passed as a whole. For this reason, we use the function named “translateByHash” that I wrote for text translations that require more than one parameter. Also, as a convenience, for a single parameter, we can write it using “%s” as in the following example:</p><pre>{{translate “Dear %s” userName}}</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c7b6b15a1f21b7c9056dc796d6e640a/href">https://medium.com/media/2c7b6b15a1f21b7c9056dc796d6e640a/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*6wu0tB1CZc7B4FFMdRgHJA.png" /><figcaption>Designed email</figcaption></figure><h4>Example project coding</h4><p>You can access the project file that I have compiled and corrected the codes I have given above code pieces from the GitHub link below.</p><p><a href="https://github.com/nabiguzel/designed-email-sender">GitHub - nabiguzel/designed-email-sender: Designed and Localized Email Sender</a></p><h3>Conclusion</h3><p>Thanks to this structure we have developed, we have ensured that the emails of the system sent to the users are filed as structure and coding, followed up and coded more properly, the design is better in appearance, and the texts included are language-variable.</p><p>Good coding…</p><h3>References</h3><ul><li><a href="http://www.umutozel.com/handlebars-js">Yeni Başlayanlar için Handlebars.js</a></li><li><a href="https://waelyasmina.medium.com/a-guide-into-using-handlebars-with-your-express-js-application-22b944443b65">A Step By Step Guide To Using Handlebars With Your Node js Application</a></li><li><a href="https://medium.com/jsblend/how-to-send-emails-with-templates-using-nodejs-176b72c1406d">How to Send Emails With Templates using NodeJs</a></li><li><a href="https://www.npmjs.com/package/i18n">i18n</a></li><li><a href="https://nodemailer.com/about/">Nodemailer</a></li><li><a href="https://handlebarsjs.com/">Handlebars</a></li><li><a href="https://github.com/ericf/express-handlebars">GitHub - ericf/express-handlebars: A Handlebars view engine for Express which doesn&#39;t suck.</a></li><li><a href="https://github.com/yads/nodemailer-express-handlebars">GitHub - yads/nodemailer-express-handlebars: A plugin for nodemailer that uses express-handlebars view engine to generate emails</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efa574211c78" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/node-js-express-js-send-localized-emails-with-templates-efa574211c78">👨🏼‍💻Node.js, Express.js | Send Localized Emails With Templates</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>