<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://mustafadalga.github.io/blog/blog/feed.xml" rel="self" type="application/atom+xml" /><link href="https://mustafadalga.github.io/blog/blog/" rel="alternate" type="text/html" /><updated>2026-11-26T19:08:52+00:00</updated><id>https://mustafadalga.github.io/blog/blog/feed.xml</id><title type="html">Mustafa Dalga - Frontend Performance &amp;amp; Modernization Specialist</title><entry><title type="html">Standard Inconsistencies and My Solution in the Front End Team</title><link href="https://mustafadalga.github.io/blog/blog/standard-inconsistencies-and-my-solution-in-the-front-end-team/" rel="alternate" type="text/html" title="Standard Inconsistencies and My Solution in the Front End Team" /><published>2024-11-28T19:59:22+00:00</published><updated>2024-11-28T19:59:22+00:00</updated><id>https://mustafadalga.github.io/blog/blog/standard-inconsistencies-and-my-solution-in-the-front-end-team</id><content type="html" xml:base="https://mustafadalga.github.io/blog/blog/standard-inconsistencies-and-my-solution-in-the-front-end-team/"><![CDATA[<p>As a Front End Developer, I want to share in this blog post how I established a common coding standard within the project and team, and the problems I encountered during this process.</p>

<p><strong>Code Development and Standards</strong></p>

<p>After developing our code, we always send it to code review with a pull request. However, I noticed that adhering to certain standards was a challenge in this process. I was trying to establish a standard way of writing in the project, but we encountered many issues such as the following:</p>

<p>• <strong>Variable Naming:</strong> We were using camelCase, but some developers did not follow this standard.</p>

<p>• <strong>Enum Naming:</strong> Enum names in legacy code were written in camelCase, while in the new code PascalCase was used. Finally, we decided to name enums and their properties using PascalCase.</p>

<p>• <strong>Function Definition:</strong> We previously used arrow functions, but due to code order issues, we started using declaration functions. However, developers had difficulty transitioning to this new standard. For example, functions used in the onMounted hook were defined as arrow functions, which broke code order rules.</p>

<p>• <strong>Vue.js Standards:</strong> With Vue.js 3, we started using the composition API and TypeScript. However, some developers were still working with the options API or defineComponent.</p>

<p>• <strong>Vue.js Component Block Order:</strong> The code was being developed in the order of “script,” “template,” and “style.” Despite this, some developers still placed the template block at the top.</p>

<p>• <strong>Props Naming:</strong> Props were generally written in camelCase, but in some cases, kebab-case was used.</p>

<p><strong>Setting and Applying Standards</strong></p>

<p>To address these issues, I prepared documentation outlining the standards and rules I defined, and shared it with the team. However, I realized that the documentation was not being read, and the standards were not being taken seriously. This caused me to give the same feedback repeatedly during code review processes.</p>

<p><strong>Solution: Eslint, Prettier, and Lint-Staged</strong></p>

<p>When I noticed that documentation was not effective enough, I took the following steps:</p>

<p>1. <strong>Eslint Rules:</strong> I configured Eslint rules to align with the standards in the documentation.</p>

<p>2. <strong>Code Formatting:</strong> I set up .editorconfig and .prettierrc files to address code formatting issues.</p>

<p>3. <strong>Using Lint-Staged:</strong> Since it was not feasible to fix all the old code, I used the lint-staged tool to focus only on the changes being committed. This ensured that the development became more consistent.</p>

<p><strong>Build and Demo Issues</strong></p>

<p>Another frequent problem during code review and demo was that the code would fail to build. This was often due to TypeScript errors or non-functional unit tests, which were discovered only during deployment. In such cases, the code was sent back to in-progress, and we had to review it twice. To prevent this:</p>

<p>• I configured the lint-staged tool to run unit tests and type checking before commits. This way, issues were identified and resolved before the commit stage.</p>

<hr />

<p>I have explained the issues we experienced as a Front End team and how I resolved them in general. The standards I shared here are completely tailored to our team’s needs. Different teams may need to determine their own standards.</p>

<p>https://gist.github.com/mustafadalga/3b026306bae517c2d72ffa884185171c</p>]]></content><author><name></name></author><category term="front-end-development" /><category term="problem-solving" /><category term="team-management" /><category term="coding-standards" /><category term="codingstandards" /><summary type="html"><![CDATA[As a Front End Developer, I want to share in this blog post how I established a common coding standard within the project and team, and the problems I encountered during this process.]]></summary></entry><entry><title type="html">Front End Takımındaki Standart Uyumsuzlukları ve Çözümüm</title><link href="https://mustafadalga.github.io/blog/blog/front-end-takimindaki-standart-uyumsuzluklari-ve-cozumum/" rel="alternate" type="text/html" title="Front End Takımındaki Standart Uyumsuzlukları ve Çözümüm" /><published>2024-11-19T22:00:00+00:00</published><updated>2024-11-19T22:00:00+00:00</updated><id>https://mustafadalga.github.io/blog/blog/front-end-takimindaki-standart-uyumsuzluklari-ve-cozumum</id><content type="html" xml:base="https://mustafadalga.github.io/blog/blog/front-end-takimindaki-standart-uyumsuzluklari-ve-cozumum/"><![CDATA[<p>Front End Developer olarak çalışırken projede ve takım içinde ortak bir yazma standardını nasıl belirlediğimi ve bu süreçte yaşadığım sorunları bu blog yazısında paylaşmak istiyorum.</p>

<p><strong>Kod Geliştirme ve Standartlar</strong></p>

<p>Kodlarımızı geliştirdikten sonra her zaman pull request ile code review’e gönderiyoruz. Ancak bu süreçte belli başlı standartlara uymakta zorlanıldığını fark ettim. Projede standart bir yazım dili oturtmaya çalışıyordum, ancak aşağıdaki gibi birçok sorunla karşılaştık:</p>

<p>• <strong>Değişken İsimlendirme:</strong> CamelCase kullanıyorduk, fakat bazı geliştiriciler bu standarda uymuyordu.</p>

<p>• <strong>Enum İsimlendirme:</strong> Legacy kodlarda enum isimleri camelCase ile yazılmıştı, yeni kodlarda ise PascalCase kullanılıyordu. Sonunda enum isimlendirme ve property’lerini PascalCase yapmaya karar verdik.</p>

<p>• <strong>Fonksiyon Tanımlama:</strong> Daha önce arrow function kullanıyorduk, fakat hizalama sorunları nedeniyle declaration function kullanmaya başladık. Ancak geliştiriciler bu yeni standarda geçmekte zorlanıyordu. Örneğin, onMounted hook’unda kullanılan fonksiyonlar arrow olarak tanımlanıyordu ve hizalama kurallarını bozuyordu.</p>

<p>• <strong>Vue.js Standartları:</strong> Vue.js 3 ile birlikte composition API ve TypeScript kullanmaya başladık. Ancak bazı geliştiriciler hala options API veya defineComponent ile çalışıyordu.</p>

<p>• <strong>Vue componentleri Blok Sıralaması:</strong> Kodlar “script”, “template”, “style” sırasıyla geliştirilmeye başlanmıştı. Buna rağmen bazıları hala template bloğunu en üste koyuyordu.</p>

<p>• <strong>Props İsimlendirme:</strong> Propslar genelde camelCase ile yazılıyordu, fakat bazı yerlerde kebab-case kullanılıyordu.</p>

<p><strong>Standartların Belirlenmesi ve Uygulanması</strong></p>

<p>Bu sorunları çözmek için, belirlediğim standartları ve kuralları içeren dokümantasyonlar hazırladım ve takımla paylaştım. Ancak, dokümantasyonların okunmadığını ve standartlara yeterince önem verilmediğini fark ettim. Bu, code review süreçlerinde sürekli aynı geri bildirimleri vermeme neden oluyordu.</p>

<p><strong>Çözüm: Eslint, Prettier ve Lint-Staged</strong></p>

<p>Dokümantasyonların yeterince etkili olmadığını fark edince şu adımları izledim:</p>

<p>1. <strong>Eslint Kuralları:</strong> Dokümantasyondaki standartlara uygun olarak Eslint kurallarını yapılandırdım.</p>

<p>2. <strong>Kod Formatlama:</strong> Kod formatlama sorunları için .editorconfig ve .prettierrc dosyalarını yapılandırdım.</p>

<p>3. <strong>Lint-Staged Kullanımı:</strong> Eski kodların tamamını düzeltmek mümkün olmadığından, lint-staged aracını kullanarak sadece commitlenecek geliştirmelere odaklandım. Bu, geliştirmelerin daha tutarlı olmasını sağladı.</p>

<p><strong>Build ve Demo Sorunları</strong></p>

<p>Code review ve demo sırasında sıkça karşılaşılan bir başka sorun, kodların build olmamasıydı. Typescript hataları veya unit testlerin çalışmaması nedeniyle deployment sırasında hatalar fark ediliyordu. Bu durumda kod tekrar inprogress’e gönderiliyordu ve iki kere bakmak durumunda kalıyorduk. Bunun önüne geçmek için:</p>

<p>• Lint-staged aracını, commit öncesinde unit test ve type checking yapacak şekilde yapılandırdım. Böylece, sorunlar daha commit aşamasında tespit edilip çözülüyordu.</p>

<hr />

<p>Front End takımı olarak yaşadığımız sorunları ve bunları nasıl çözdüğümü genel hatlarıyla anlattım. Burada paylaştığım standartlar tamamen takımımızın ihtiyaçlarına göre belirlenmiştir. Her ekibin kendi ihtiyaçlarına göre farklı standartlar belirlemesi gerekebilir.</p>

<p><strong>Proje Yapılandırma dosyaları</strong></p>

<p>https://gist.github.com/mustafadalga/3b026306bae517c2d72ffa884185171c</p>]]></content><author><name></name></author><category term="front-end-development" /><category term="problem-solving" /><category term="team-management" /><category term="coding-standards" /><category term="codingstandards" /><summary type="html"><![CDATA[Front End Developer olarak çalışırken projede ve takım içinde ortak bir yazma standardını nasıl belirlediğimi ve bu süreçte yaşadığım sorunları bu blog yazısında paylaşmak istiyorum.]]></summary></entry><entry><title type="html">Soru Sormaktan ve Eleştirmekten Korkmak</title><link href="https://mustafadalga.github.io/blog/blog/soru-sormaktan-ve-elestirmekten-korkmak/" rel="alternate" type="text/html" title="Soru Sormaktan ve Eleştirmekten Korkmak" /><published>2024-06-24T05:04:15+00:00</published><updated>2024-06-24T05:04:15+00:00</updated><id>https://mustafadalga.github.io/blog/blog/soru-sormaktan-ve-elestirmekten-korkmak</id><content type="html" xml:base="https://mustafadalga.github.io/blog/blog/soru-sormaktan-ve-elestirmekten-korkmak/"><![CDATA[<p><img src="/blog/assets/images/43db1957bf0d604c73a51755f374a152.jpeg" alt="Cover Image" /></p>

<p>Son günlerde Türkiye’de bir YouTuber, şeriat ve Hz. Muhammed hakkında eleştirel konuştuğu için ölüm tehditleri aldı ve hakkında yakalama kararı çıkarıldı. Bu olay, ülkede yaygın olan inançları yada fikirleri sorguladığınızda başınıza nelerin geldiğini gösteren sıradan bir örnek.</p>

<p>İnsanların soru sormasına ve dogmaları eleştirmesine izin verilmeyen yerlerde toplum yerinde sayar. Mesela Estonya gibi ülkelere baktığınızda insanlar her şeyi rahatça sorgulayabiliyor, yöneticilerden hesap sorabiliyor ve kimse fikirleri yüzünden tehdit edilmiyor yada hapse atılmıyor. Sorgulama kültürü olduğu için şeffaflık var ve işler ilerliyor.</p>

<p>Türkiye’de ise durum tam tersi işliyor. Belli gruplar ve siyasetçiler insanlardan körü körüne inanmalarını bekliyor, en ufak bir eleştiriyi yada sorgulamayı hemen suç gibi gösteriyorlar. Kimsenin soru sormadığı, her şeye sorgusuz sualsiz inandığı bir ortamda kötü niyetli insanlar halkı çok rahat sömürüyor ve istediği gibi yönlendiriyor.</p>

<p>İnsanları yakalama kararlarıyla ve tehditlerle susturmak kimseyi korumuyor, sadece insanların kendi kafasıyla düşünmesini engelleyip aynı düzenin devam etmesini sağlıyor.</p>]]></content><author><name></name></author><category term="education" /><category term="critical-thinking" /><category term="free-speech" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">The Fear of Asking Questions</title><link href="https://mustafadalga.github.io/blog/blog/the-fear-of-asking-questions/" rel="alternate" type="text/html" title="The Fear of Asking Questions" /><published>2024-06-24T05:04:15+00:00</published><updated>2024-06-24T05:04:15+00:00</updated><id>https://mustafadalga.github.io/blog/blog/the-fear-of-asking-questions</id><content type="html" xml:base="https://mustafadalga.github.io/blog/blog/the-fear-of-asking-questions/"><![CDATA[<p><img src="/blog/assets/images/43db1957bf0d604c73a51755f374a152.jpeg" alt="Cover Image" /></p>

<p>Recently, a YouTuber Diamond Tema in Turkey got serious death threats and an arrest warrant just for speaking critically about Sharia law and the Prophet Muhammad. This is just one example of what happens in Turkey when someone openly questions religious beliefs or popular ideas.</p>

<p>When people aren’t allowed to ask questions or criticize dogmas, society gets stuck. Take a country like Estonia for example. People there openly question things, hold leaders accountable, and criticize systems without getting arrested or threatened. Because nobody is scared to ask questions, there is transparency and things actually improve.</p>

<p>In Turkey it works the exact opposite way. Certain religious groups and politicians push blind faith and treat any criticism as a crime. They don’t want people asking questions or thinking critically. When a society is trained to believe blindly without questioning anything, bad people easily take advantage of that and manipulate everyone.</p>

<p>Silencing people with arrest warrants and threats doesn’t protect society, it just keeps everyone afraid to think for themselves and lets the same people stay in control.</p>]]></content><author><name></name></author><category term="education" /><category term="critical-thinking" /><category term="free-speech" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Mazlum Güçlenince Zalim Oluyor</title><link href="https://mustafadalga.github.io/blog/blog/mazlum-guclenince-zalim-oluyor/" rel="alternate" type="text/html" title="Mazlum Güçlenince Zalim Oluyor" /><published>2024-06-01T07:31:37+00:00</published><updated>2024-06-01T07:31:37+00:00</updated><id>https://mustafadalga.github.io/blog/blog/mazlum-guclenince-zalim-oluyor</id><content type="html" xml:base="https://mustafadalga.github.io/blog/blog/mazlum-guclenince-zalim-oluyor/"><![CDATA[<p>Lord Acton’un “Güç yozlaştırır, mutlak güç kesin olarak yozlaştırır” sözü tarihte defalarca kanıtlanmış bir gerçek. Bir zamanlar ezilen, zulüm gören insanlar eline sınırsız güç geçirdiğinde kendileri de aynı zalimliği yapmaya başlıyor.</p>

<p>Bunun en net örneklerinden biri İsrail meselesi. Yahudiler İkinci Dünya Savaşı’nda çok büyük acılar çekti ve soykırıma uğradı. Ama kendi devletleri kurulduktan ve askeri güç ellerine geçtikten sonra, bu sefer Filistinlilere karşı uyguladıkları baskı ve şiddet bir çok kişi tarafından soykırım olarak görülüyor. Dün ezilen taraf, güçlenince başkalarını ezen tarafa dönüştü.</p>

<p>Çin’deki Kültür Devrimi de aynı şekilde ilerledi. Mao Zedong önderliğindeki hareket ilk başta eşitlik ve adalet getireceğini söyleyerek yola çıktı. Ama gücü ele geçirdikten sonra kendilerine karşı çıkan herkese ağır baskılar yaptılar. Eskiden savaştıkları o zalim yöneticiler kadar acımasız oldular ve kendi halklarına çok büyük zararlar verdiler.</p>

<p>Sovyetler Birliği’nde de farklı bir şey yaşanmadı. Devrimden önce ezilen işçi sınıfı iktidarı aldıktan sonra Stalin döneminde korkunç bir baskı rejimi kurdu. Milyonlarca insan Gulag kamplarına atıldı, sürgüne gönderildi yada öldürüldü. Yani bir zamanlar mazlum olanlar koltuğa oturunca aynı zulmü başkalarına uyguladı.</p>

<p>İnsan doğası gereği eline sınırsız yetki geçince kendini kaybediyor ve kontrolden çıkıyor. Gücün sınırlandırılmadığı, denetim ve güçler ayrılığının olmadığı bir yerde kimsenin iyi niyetine yada merhametine güvenilmez. Sınırsız güç kimin eline geçerse geçsin sonuç hep aynı oluyor.</p>]]></content><author><name></name></author><category term="iktidar" /><category term="diktatorluk" /><summary type="html"><![CDATA[Lord Acton’un “Güç yozlaştırır, mutlak güç kesin olarak yozlaştırır” sözü tarihte defalarca kanıtlanmış bir gerçek. Bir zamanlar ezilen, zulüm gören insanlar eline sınırsız güç geçirdiğinde kendileri de aynı zalimliği yapmaya başlıyor.]]></summary></entry><entry><title type="html">When Victims Get Power, They Become the Oppressors</title><link href="https://mustafadalga.github.io/blog/blog/when-victims-get-power-they-become-the-oppressors/" rel="alternate" type="text/html" title="When Victims Get Power, They Become the Oppressors" /><published>2024-06-01T07:31:37+00:00</published><updated>2024-06-01T07:31:37+00:00</updated><id>https://mustafadalga.github.io/blog/blog/when-victims-get-power-they-become-the-oppressors</id><content type="html" xml:base="https://mustafadalga.github.io/blog/blog/when-victims-get-power-they-become-the-oppressors/"><![CDATA[<p>Lord Acton’s famous quote, “Power tends to corrupt, and absolute power corrupts absolutely,” has been proven right over and over again in history. Whenever people who used to be oppressed finally get power in their hands, they usually start doing the exact same cruel things to others.</p>

<p>One clear example is Israel. Jewish people went through terrible suffering and genocide during World War II. But after the state of Israel was created and they gained military power, the violence and oppression they put on Palestinians is now called a genocide by a lot of people. Yesterday’s victims turned into today’s oppressors once they got the power.</p>

<p>The exact same thing happened during the Chinese Cultural Revolution. The movement under Mao Zedong started out promising equality and justice. But once they got control, they crushed anyone who disagreed with them. They became just as brutal as the rulers they fought against and caused massive harm to their own people.</p>

<p>The Soviet Union was no different. Before the revolution, the working class was oppressed and treated badly. Once they took power under Stalin, they built a brutal dictatorship where millions of people were thrown into Gulag camps, exiled, or killed. The people who were once victims did the exact same thing when they sat in the seat of power.</p>

<p>By nature, humans lose control when they have unlimited power. Anywhere there are no strict checks, balances, or limits on authority, relying on a leader’s good intentions or mercy always fails. No matter who gets absolute power, it always ends the exact same way.</p>]]></content><author><name></name></author><category term="iktidar" /><category term="diktatorluk" /><summary type="html"><![CDATA[Lord Acton’s famous quote, “Power tends to corrupt, and absolute power corrupts absolutely,” has been proven right over and over again in history. Whenever people who used to be oppressed finally get power in their hands, they usually start doing the exact same cruel things to others.]]></summary></entry><entry><title type="html">Creating a Reusable Axios Wrapper: A Clean and Efficient Approach</title><link href="https://mustafadalga.github.io/blog/blog/creating-a-reusable-axios-wrapper-a-clean-and-efficient-approach/" rel="alternate" type="text/html" title="Creating a Reusable Axios Wrapper: A Clean and Efficient Approach" /><published>2024-05-18T08:25:15+00:00</published><updated>2024-05-18T08:25:15+00:00</updated><id>https://mustafadalga.github.io/blog/blog/creating-a-reusable-axios-wrapper-a-clean-and-efficient-approach</id><content type="html" xml:base="https://mustafadalga.github.io/blog/blog/creating-a-reusable-axios-wrapper-a-clean-and-efficient-approach/"><![CDATA[<p>In one of our projects, we use the axios library to make API requests to our backend REST endpoints. However, we need to add authorization headers to these API requests. After the user logs in, we store the JWT token received from the backend and send this token in the authorization header for each API request to ensure proper authentication.</p>

<p>Initially, we were inefficiently adding the JWT token to the axios headers for every API request. Here’s a simple example of how it was done:</p>

<div class="language-typescript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">export</span> <span class="kd">function</span> <span class="nx">useGetPosts</span><span class="p">()</span> <span class="p">{</span>
  <span class="kd">const</span> <span class="nx">store</span> <span class="o">=</span> <span class="nx">useStore</span><span class="p">();</span>
  <span class="kd">const</span> <span class="nx">apiURL</span> <span class="o">=</span> <span class="k">import</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">API_BASE_URL</span><span class="p">;</span>
  <span class="kd">const</span> <span class="nx">jwt</span> <span class="o">=</span> <span class="nx">computed</span><span class="p">(()</span> <span class="o">=&gt;</span> <span class="nx">store</span><span class="p">.</span><span class="nx">getters</span><span class="p">.</span><span class="nx">getJWT</span><span class="p">);</span>

  <span class="k">async</span> <span class="kd">function</span> <span class="nx">getPosts</span><span class="p">()</span> <span class="p">{</span>
    <span class="kd">const</span> <span class="nx">response</span> <span class="o">=</span> <span class="k">await</span> <span class="nx">axios</span><span class="p">.</span><span class="kd">get</span><span class="p">(</span><span class="s2">`</span><span class="p">${</span><span class="nx">apiURL</span><span class="p">}</span><span class="s2">/posts`</span><span class="p">,</span> <span class="p">{</span>
      <span class="na">headers</span><span class="p">:</span> <span class="p">{</span>
        <span class="na">Authorization</span><span class="p">:</span> <span class="nx">jwt</span><span class="p">.</span><span class="nx">value</span><span class="p">,</span>
      <span class="p">},</span>
    <span class="p">});</span>
    <span class="k">return</span> <span class="nx">response</span><span class="p">;</span>
  <span class="p">}</span>

  <span class="k">return</span> <span class="p">{</span>
    <span class="nx">getPosts</span><span class="p">,</span>
  <span class="p">};</span>
<span class="p">}</span>
</code></pre></div></div>

<p>Additionally, since our project operates on a client basis, it is essential to synchronize the client’s information whenever it changes. Therefore, all pending API requests must be canceled when the client changes, as these requests are intended to load information for the previous client and are no longer needed. To cancel unnecessary network requests, we needed to add cancel tokens to each API request.</p>

<p>When your MacBook goes into sleep mode, it cuts off the internet connection to save energy, causing network errors for background web applications. In our project, we have background processes that send periodic REST API requests to update data, but these API requests result in network errors when the MacBook enters sleep mode. To handle this issue, we needed to use axios response error interceptors to ignore the errors.</p>

<p>Handling the above three cases for each API request would result in unnecessarily messy code. Therefore, I created an axios wrapper composable to provide a clean and reusable solution.</p>

<div class="language-typescript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">import</span> <span class="p">{</span> <span class="nx">useStore</span> <span class="p">}</span> <span class="k">from</span> <span class="dl">"</span><span class="s2">vuex</span><span class="dl">"</span><span class="p">;</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">computed</span> <span class="p">}</span> <span class="k">from</span> <span class="dl">"</span><span class="s2">vue</span><span class="dl">"</span><span class="p">;</span>
<span class="k">import</span> <span class="nx">axios</span> <span class="k">from</span> <span class="dl">"</span><span class="s2">axios</span><span class="dl">"</span><span class="p">;</span>
<span class="k">import</span> <span class="kd">type</span> <span class="p">{</span> <span class="nx">InternalAxiosRequestConfig</span><span class="p">,</span> <span class="nx">CancelTokenSource</span><span class="p">,</span> <span class="nx">AxiosInstance</span><span class="p">,</span> <span class="nx">AxiosError</span> <span class="p">}</span> <span class="k">from</span> <span class="dl">"</span><span class="s2">axios</span><span class="dl">"</span><span class="p">;</span>

<span class="kr">interface</span> <span class="nx">IExtendedAxiosError</span> <span class="kd">extends</span> <span class="nx">AxiosError</span> <span class="p">{</span>
    <span class="nl">toJSON</span><span class="p">:</span> <span class="p">()</span> <span class="o">=&gt;</span> <span class="nb">Record</span><span class="o">&lt;</span><span class="kr">string</span><span class="p">,</span> <span class="nx">unknown</span><span class="o">&gt;</span><span class="p">;</span>
<span class="p">}</span>

<span class="k">export</span> <span class="k">default</span> <span class="kd">function</span> <span class="nx">useAxios</span><span class="p">()</span> <span class="p">{</span>
    <span class="kd">const</span> <span class="nx">store</span> <span class="o">=</span> <span class="nx">useStore</span><span class="p">();</span>
    <span class="kd">const</span> <span class="nx">jwt</span> <span class="o">=</span> <span class="nx">computed</span><span class="o">&lt;</span><span class="kr">string</span><span class="o">&gt;</span><span class="p">(()</span> <span class="o">=&gt;</span> <span class="nx">store</span><span class="p">.</span><span class="nx">getters</span><span class="p">.</span><span class="nx">getJWT</span><span class="p">);</span>
    <span class="kd">const</span> <span class="nx">axiosCancelToken</span> <span class="o">=</span> <span class="nx">computed</span><span class="o">&lt;</span><span class="nx">CancelTokenSource</span><span class="o">&gt;</span><span class="p">(()</span> <span class="o">=&gt;</span> <span class="nx">store</span><span class="p">.</span><span class="nx">getters</span><span class="p">.</span><span class="nx">getAxiosCancelToken</span><span class="p">);</span>
    <span class="kd">const</span> <span class="nx">axiosInstance</span><span class="p">:</span> <span class="nx">AxiosInstance</span> <span class="o">=</span> <span class="nx">axios</span><span class="p">.</span><span class="nx">create</span><span class="p">({</span>
        <span class="na">baseURL</span><span class="p">:</span> <span class="nx">store</span><span class="p">.</span><span class="nx">getters</span><span class="p">.</span><span class="nx">getApiBaseUrl</span>
    <span class="p">});</span>

    <span class="nx">setup</span><span class="p">();</span>

    <span class="kd">function</span> <span class="nx">setup</span><span class="p">()</span> <span class="p">{</span>
        <span class="nx">axiosInstance</span><span class="p">.</span><span class="nx">interceptors</span><span class="p">.</span><span class="nx">request</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">onRequest</span><span class="p">,</span> <span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="o">=&gt;</span> <span class="nb">Promise</span><span class="p">.</span><span class="nx">reject</span><span class="p">(</span><span class="nx">error</span><span class="p">));</span>
        <span class="nx">axiosInstance</span><span class="p">.</span><span class="nx">interceptors</span><span class="p">.</span><span class="nx">response</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">response</span> <span class="o">=&gt;</span> <span class="nx">response</span><span class="p">,</span> <span class="nx">onResponseError</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="kd">function</span> <span class="nx">onRequest</span><span class="p">(</span><span class="nx">config</span><span class="p">:</span> <span class="nx">InternalAxiosRequestConfig</span><span class="p">):</span> <span class="nx">InternalAxiosRequestConfig</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">config</span><span class="p">.</span><span class="nx">headers</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">config</span><span class="p">.</span><span class="nx">headers</span><span class="p">.</span><span class="nx">Authorization</span> <span class="o">=</span> <span class="nx">jwt</span><span class="p">.</span><span class="nx">value</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="nx">config</span><span class="p">.</span><span class="nx">cancelToken</span> <span class="o">=</span> <span class="nx">axiosCancelToken</span><span class="p">.</span><span class="nx">value</span><span class="p">.</span><span class="nx">token</span><span class="p">;</span>
        <span class="k">return</span> <span class="nx">config</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="kd">function</span> <span class="nx">onResponseError</span><span class="p">(</span><span class="nx">error</span><span class="p">:</span> <span class="nx">IExtendedAxiosError</span><span class="p">):</span> <span class="nb">Promise</span><span class="o">&lt;</span><span class="nx">AxiosError</span><span class="o">&gt;</span> <span class="o">|</span> <span class="kc">undefined</span> <span class="p">{</span>
        <span class="kd">const</span> <span class="nx">isNetworkError</span> <span class="o">=</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">hasOwn</span><span class="p">(</span><span class="nx">error</span><span class="p">,</span> <span class="dl">"</span><span class="s2">toJSON</span><span class="dl">"</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="nx">error</span><span class="p">.</span><span class="nx">toJSON</span><span class="p">().</span><span class="nx">message</span> <span class="o">==</span> <span class="dl">"</span><span class="s2">Network Error</span><span class="dl">"</span><span class="p">;</span>
        <span class="k">return</span> <span class="nx">isNetworkError</span> <span class="p">?</span> <span class="kc">undefined</span> <span class="p">:</span> <span class="nb">Promise</span><span class="p">.</span><span class="nx">reject</span><span class="p">(</span><span class="nx">error</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">return</span> <span class="p">{</span>
        <span class="na">axios</span><span class="p">:</span> <span class="nx">axiosInstance</span>
    <span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>

<p>Here’s the store where I keep and update the JWT, cancel token, and API URL:</p>

<div class="language-typescript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">import</span> <span class="p">{</span> <span class="nx">createStore</span> <span class="p">}</span> <span class="k">from</span> <span class="dl">'</span><span class="s1">vuex</span><span class="dl">'</span>
<span class="k">import</span> <span class="nx">axios</span><span class="p">,</span> <span class="p">{</span> <span class="kd">type</span> <span class="nx">CancelTokenSource</span> <span class="p">}</span> <span class="k">from</span> <span class="dl">"</span><span class="s2">axios</span><span class="dl">"</span>


<span class="k">export</span> <span class="kr">interface</span> <span class="nx">State</span> <span class="p">{</span>
    <span class="nl">axiosCancelToken</span><span class="p">:</span> <span class="nx">CancelTokenSource</span><span class="p">,</span>
    <span class="nx">jwt</span><span class="p">:</span> <span class="kr">string</span> <span class="o">|</span> <span class="kc">null</span><span class="p">,</span>
    <span class="nx">apiURL</span><span class="p">:</span> <span class="kr">string</span><span class="p">,</span>
    <span class="nx">activeClient</span><span class="p">:</span> <span class="kr">string</span> <span class="o">|</span> <span class="kc">null</span>
<span class="p">}</span>

<span class="kd">const</span> <span class="nx">store</span> <span class="o">=</span> <span class="nx">createStore</span><span class="o">&lt;</span><span class="nx">State</span><span class="o">&gt;</span><span class="p">({</span>
    <span class="na">state</span><span class="p">:</span> <span class="p">{</span>
        <span class="na">axiosCancelToken</span><span class="p">:</span> <span class="nx">axios</span><span class="p">.</span><span class="nx">CancelToken</span><span class="p">.</span><span class="nx">source</span><span class="p">(),</span>
        <span class="na">jwt</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
        <span class="na">apiURL</span><span class="p">:</span> <span class="k">import</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">API_BASE_URL</span><span class="p">,</span>
        <span class="na">activeClient</span><span class="p">:</span> <span class="kc">null</span>
    <span class="p">},</span>
    <span class="na">getters</span><span class="p">:</span> <span class="p">{</span>
        <span class="nx">getJWT</span><span class="p">(</span><span class="nx">state</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="nx">state</span><span class="p">.</span><span class="nx">jwt</span>
        <span class="p">},</span>
        <span class="nx">getAxiosCancelToken</span><span class="p">(</span><span class="nx">state</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="nx">state</span><span class="p">.</span><span class="nx">axiosCancelToken</span>
        <span class="p">},</span>
        <span class="nx">getApiURL</span><span class="p">(</span><span class="nx">state</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="nx">state</span><span class="p">.</span><span class="nx">apiURL</span>
        <span class="p">},</span>
        <span class="nx">getActiveclient</span><span class="p">(</span><span class="nx">state</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="nx">state</span><span class="p">.</span><span class="nx">activeClient</span>
        <span class="p">}</span>
    <span class="p">},</span>
    <span class="na">mutations</span><span class="p">:</span> <span class="p">{</span>
        <span class="nx">setJWT</span><span class="p">(</span><span class="nx">state</span><span class="p">,</span> <span class="nx">jwt</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">state</span><span class="p">.</span><span class="nx">jwt</span> <span class="o">=</span> <span class="nx">jwt</span>
        <span class="p">},</span>
        <span class="nx">setAxiosCancelToken</span><span class="p">(</span><span class="nx">state</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">state</span><span class="p">.</span><span class="nx">axiosCancelToken</span> <span class="o">=</span> <span class="nx">axios</span><span class="p">.</span><span class="nx">CancelToken</span><span class="p">.</span><span class="nx">source</span><span class="p">()</span>
        <span class="p">},</span>
        <span class="nx">cancelAxiosCancelToken</span><span class="p">(</span><span class="nx">state</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">state</span><span class="p">.</span><span class="nx">axiosCancelToken</span><span class="p">.</span><span class="nx">cancel</span><span class="p">();</span>
        <span class="p">},</span>
        <span class="nx">setActiveClient</span><span class="p">(</span><span class="nx">state</span><span class="p">,</span> <span class="nx">activeClient</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">state</span><span class="p">.</span><span class="nx">activeClient</span> <span class="o">=</span> <span class="nx">activeClient</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">})</span>

<span class="k">export</span> <span class="k">default</span> <span class="nx">store</span><span class="p">;</span>
</code></pre></div></div>

<p>Here’s a simple usage example:</p>

<div class="language-typescript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&lt;</span><span class="nx">script</span> <span class="nx">setup</span> <span class="nx">lang</span><span class="o">=</span><span class="dl">"</span><span class="s2">ts</span><span class="dl">"</span><span class="o">&gt;</span>
<span class="k">import</span> <span class="nx">useAxios</span> <span class="k">from</span> <span class="dl">"</span><span class="s2">@/composables/useAxios</span><span class="dl">"</span><span class="p">;</span>
<span class="k">import</span> <span class="p">{</span> <span class="nx">useStore</span> <span class="p">}</span> <span class="k">from</span> <span class="dl">"</span><span class="s2">vuex</span><span class="dl">"</span><span class="p">;</span>

<span class="kd">const</span> <span class="p">{</span> <span class="nx">axios</span> <span class="p">}</span> <span class="o">=</span> <span class="nx">useAxios</span><span class="p">();</span>
<span class="nx">getUsers</span><span class="p">();</span>

<span class="k">async</span> <span class="kd">function</span> <span class="nx">getUsers</span><span class="p">()</span> <span class="p">{</span>
  <span class="kd">const</span> <span class="nx">response</span> <span class="o">=</span> <span class="k">await</span> <span class="nx">axios</span><span class="p">.</span><span class="kd">get</span><span class="p">(</span><span class="dl">"</span><span class="s2">https://reqres.in/api/users?delay=3</span><span class="dl">"</span><span class="p">);</span>
  <span class="c1">//...</span>
<span class="p">}</span>
<span class="o">&lt;</span><span class="sr">/script</span><span class="err">&gt;
</span></code></pre></div></div>

<p>You can check out the full example in this repo: <a href="https://github.com/mustafadalga/vue-playground/tree/26.use-axios">GitHub Repo Link</a> and the demo here: <a href="https://guileless-dieffenbachia-3e85e5.netlify.app/">Demo Link</a>.</p>]]></content><author><name></name></author><category term="vuejs" /><category term="frontend-development" /><category term="axios-interceptor" /><category term="axios" /><category term="axios-https-request" /><summary type="html"><![CDATA[In one of our projects, we use the axios library to make API requests to our backend REST endpoints. However, we need to add authorization headers to these API requests. After the user logs in, we store the JWT token received from the backend and send this token in the authorization header for each API request to ensure proper authentication.]]></summary></entry><entry><title type="html">İnsanlar Kaliteyi Değil Popüler Olanı Takip Ediyor</title><link href="https://mustafadalga.github.io/blog/blog/insanlar-kaliteyi-degil-populer-olani-takip-ediyor/" rel="alternate" type="text/html" title="İnsanlar Kaliteyi Değil Popüler Olanı Takip Ediyor" /><published>2024-03-10T18:11:59+00:00</published><updated>2024-03-10T18:11:59+00:00</updated><id>https://mustafadalga.github.io/blog/blog/insanlar-kaliteyi-degil-populer-olani-takip-ediyor</id><content type="html" xml:base="https://mustafadalga.github.io/blog/blog/insanlar-kaliteyi-degil-populer-olani-takip-ediyor/"><![CDATA[<p><img src="/blog/assets/images/55843a9b-0886-4b8a-ac81-aade3b41f7b0.png" alt="Cover Image" /></p>

<p>Mark Twain’in “The Million Pound Bank Note” hikayesinde çok güzel bir örnek var. Hikayede sıradan bir restoran, zengin bir adam olan Henry Adams orada yemek yedi diye bir anda şehrin en meşhur yerine dönüşüyor. Restoranın yemeği yada kalitesi değişmiyor, sadece tanınan biri oraya gittiği için herkes oraya akın ediyor.</p>

<p>Bugün sosyal medyada dönen olay da birebir aynısı. Bir ünlü yada çok takipçili biri bir ürünü övdüğünde veya bir mekana gittiğinde, kitleler kendi kafasını hiç kullanmadan körü körüne peşinden gidiyor.</p>

<p>İstanbul’daki Ortaköy gibi turistik yerler bunun en net örneği. İnsanlar sırf internette popüler olduğu ve fotoğraf çekilmek için bu tarz yerlere doluşuyor. Çoğu kişinin derdi o mekanın gerçekten kaliteli olması yada orada güzel vakit geçirmek değil. Sadece “ben de buraya gittim” demek ve beğeni almak için gidiyorlar.</p>

<p>Herkes popüler olanı takip edince kimse kendi zevkini yada gerçekten neyden hoşlandığını keşfetmeye uğraşmıyor. İnsanlar neyin iyi olduğuna kendi tecrübesiyle değil, başkalarının kalabalığına bakarak karar veriyor ve sonunda herkes aynı yerlere gidip aynı şeyleri tüketir hale geliyor.</p>]]></content><author><name></name></author><category term="populer-kultur" /><category term="populism" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">People Follow What Is Popular, Not What Is Good</title><link href="https://mustafadalga.github.io/blog/blog/people-follow-what-is-popular-not-what-is-good/" rel="alternate" type="text/html" title="People Follow What Is Popular, Not What Is Good" /><published>2024-03-10T18:11:59+00:00</published><updated>2024-03-10T18:11:59+00:00</updated><id>https://mustafadalga.github.io/blog/blog/people-follow-what-is-popular-not-what-is-good</id><content type="html" xml:base="https://mustafadalga.github.io/blog/blog/people-follow-what-is-popular-not-what-is-good/"><![CDATA[<p><img src="/blog/assets/images/55843a9b-0886-4b8a-ac81-aade3b41f7b0.png" alt="Cover Image" /></p>

<p>There is a good example in Mark Twain’s story “The Million Pound Bank Note.” In the story, a totally ordinary restaurant suddenly turns into a famous hotspot just because a millionaire named Henry Adams ate there. The food or quality didn’t change at all, crowds just started showing up because someone rich went there.</p>

<p>On social media today, the exact same thing happens every day. Whenever a celebrity or an influencer promotes a product or visits a cafe, huge crowds blindly copy them without thinking twice.</p>

<p>Popular tourist spots like Ortaköy in Istanbul are an easy example of this. People pack into these places mainly because they are trending online and everyone takes photos there. Most of the time it has nothing to do with the actual quality of the place or the food, people just go there for the visual appeal and to get likes.</p>

<p>When everybody blindly chases whatever is trending, people stop figuring out what they actually like on their own. Instead of judging quality by their own experience, they just follow the crowd, and everyone ends up liking and doing the exact same things.</p>]]></content><author><name></name></author><category term="populer-kultur" /><category term="populism" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">How People Stop Caring When Everything Is an Emergency</title><link href="https://mustafadalga.github.io/blog/blog/how-people-stop-caring-when-everything-is-an-emergency/" rel="alternate" type="text/html" title="How People Stop Caring When Everything Is an Emergency" /><published>2024-01-20T09:46:56+00:00</published><updated>2024-01-20T09:46:56+00:00</updated><id>https://mustafadalga.github.io/blog/blog/how-people-stop-caring-when-everything-is-an-emergency</id><content type="html" xml:base="https://mustafadalga.github.io/blog/blog/how-people-stop-caring-when-everything-is-an-emergency/"><![CDATA[<p><img src="/blog/assets/images/5f13395c2978f57324f54c8996e2f253.jpeg" alt="Cover Image" /></p>

<p>People have certain sensitivities and alarm buttons. If you keep playing with those sensitivities for no real reason, after a while you break them. Eventually people get numb and start treating real emergencies like they are totally normal.</p>

<p>You see a very simple example of this in traffic. Ambulances, police cars, and fire trucks often turn on their sirens even when there is no real emergency, just to get through traffic faster. Drivers notice this and over time they stop taking sirens seriously. Then when there is a real life-or-death emergency, people don’t react fast anymore.</p>

<p>The exact same thing happens at work. Because we work remotely, our team uses Slack for communication. Some coworkers constantly send me fragmented, unnecessary messages one after another for tiny coding issues that aren’t urgent at all. Because my Slack is always blowing up, when there is an actual urgent problem it is hard for me to even notice or take it seriously.</p>

<p>Politics and religion work the exact same way. Political parties constantly abuse people’s national feelings for cheap votes. In Turkey, because most people are Muslim, religious groups and politicians keep using religion to manipulate everyone. After getting played like that over and over, people lose those sensitivities and stop trusting anyone.</p>

<p>It is the same in the economy and education too. When citizens get used to non-stop inflation every single month, they become numb to economic crises. As the Turkish Lira keeps losing value, people lose trust in their own currency and move their money elsewhere. Constant instability in the education system also kills students’ and parents’ trust in schools.</p>

<p>Whether people do it on purpose or by accident, once you overuse someone’s emotional triggers and alarm buttons, all that is left is numbness and zero trust.</p>]]></content><author><name></name></author><category term="duyarlilik" /><category term="davranisbilimi" /><category term="sosyaletkilesimler" /><category term="insanpsikolojisi" /><category term="toplumsalduyarlilik" /><summary type="html"><![CDATA[]]></summary></entry></feed>