<?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 Leisure Rife on Medium]]></title>
        <description><![CDATA[Stories by Leisure Rife on Medium]]></description>
        <link>https://medium.com/@flytoleisure?source=rss-13aaacbd0f66------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*kKrVijUlAWXruzJZ.jpg</url>
            <title>Stories by Leisure Rife on Medium</title>
            <link>https://medium.com/@flytoleisure?source=rss-13aaacbd0f66------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 12:18:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@flytoleisure/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[That Time I Confused a ? a : b with a ?? b in JavaScript]]></title>
            <link>https://flytoleisure.medium.com/that-time-i-confused-a-a-b-with-a-b-in-javascript-4f8a5bc26ae1?source=rss-13aaacbd0f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f8a5bc26ae1</guid>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[nullish-coalescing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[ternary-operator]]></category>
            <dc:creator><![CDATA[Leisure Rife]]></dc:creator>
            <pubDate>Sun, 24 Aug 2025 10:22:40 GMT</pubDate>
            <atom:updated>2025-08-24T16:28:01.429Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Difference Between the Ternary Operator (?:) and the Nullish Coalescing Operator (??) in JavaScript</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oRNujeHFmWVBRByQpTIrBw.png" /></figure><h3>Introduction</h3><p>At first, I thought a ? a : b had the same meaning as a ?? b.</p><p>But I was wrong.</p><p>This article explains the difference between checking for nullish values and checking for falsy values in JavaScript. It also shows which expressions are evaluated as nullish and which as falsy.</p><p>It’s also a cheat sheet to remind myself which condition is being used while coding.</p><h4>Example</h4><p>For nullish logic, only null and undefined are considered nullish.<br>So in x = a ?? b, the value of x will be a unless a is null or undefined.<br>For example: if a = ‘’ (empty string), then x = a will be ’’ .</p><p>But in x = a ? a : b, the condition checks if a is falsy.<br>So: if a = ‘’, then x = b.</p><h3>In Short: The Conclusion</h3><p>In x = a ?? b, the expression checks whether a is nullish.</p><p>In x = a ? a : b, the expression checks whether a is falsy.</p><h3>Cheat sheet</h3><h4>Nullish vs Falsy Operators</h4><p>Among the commonly used operators, only ?? is nullish-aware.<br>The others (?, ||, if(), etc.) all work with falsy logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IpqqGMuBP51mQF5Gos_AFA.png" /></figure><h4>Nullish vs Falsy Table</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IjCLFfL1RIrm5PXs8pGa8A.png" /></figure><h3>Code for Testing</h3><pre>const testValues = [<br> { label: “null”, value: null },<br> { label: “undefined”, value: undefined },<br> { label: “empty string ‘’”, value: “” },<br> { label: “‘hello’”, value: “hello” },<br> { label: “0”, value: 0 },<br> { label: “-1”, value: -1 },<br> { label: &quot;NaN&quot;, value: NaN },<br> { label: “false”, value: false },<br> { label: “[]”, value: [] },<br> { label: “{}”, value: {} },<br>];<br><br>const results = testValues.map(({ label, value }) =&gt; ({<br> &#39;value of a&#39; : label,<br> &#39;type of a&#39;: typeof value,<br> &#39;a ?? &quot;default&quot;&#39;: value ?? &quot;default&quot;, // shows result of ??<br> &#39;a ? a : &quot;default&quot;&#39;: value ? value : &quot;default&quot;, // shows result of ?:<br> IsNullish: value == null, // true only for null/undefined<br> IsFalsy: !value // true for falsy values<br>}));<br>console.table(results);</pre><h3>Reference</h3><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator">Conditional (ternary) operator</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing">Nullish coalescing operator</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f8a5bc26ae1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guideline for Building a Practical and Effective RAG (Retrieval-Augmented Generation) Application]]></title>
            <link>https://flytoleisure.medium.com/guideline-for-building-a-practical-and-effective-rag-retrieval-augmented-generation-application-f6cf50676e37?source=rss-13aaacbd0f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6cf50676e37</guid>
            <category><![CDATA[azure-ai-search]]></category>
            <category><![CDATA[retrieval-augmented]]></category>
            <category><![CDATA[generative-ai-solution]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[vector-search]]></category>
            <dc:creator><![CDATA[Leisure Rife]]></dc:creator>
            <pubDate>Sat, 08 Mar 2025 03:55:27 GMT</pubDate>
            <atom:updated>2025-04-06T06:57:48.933Z</atom:updated>
            <content:encoded><![CDATA[<p>Last updated: April 6th, 2025</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*Wh-FpvkUEnLW2ABiGBJE3A.jpeg" /><figcaption>generated by <a href="https://deepai.org/machine-learning-model/text2img">DeepAI</a> &amp; <a href="https://pixlr.com/">pixlr</a></figcaption></figure><h3>Preface</h3><p>This article is based on my hands-on experience in building practical and effective Retrieval-Augmented Generation (RAG) applications. Rather than just walking through the setup, I’ll focus on what truly matters — making RAG useful in real-world scenarios.<br>If you have insights, alternative approaches, or suggestions, I’d love to hear them!</p><p>I assume you’re already familiar with the <a href="https://learn.microsoft.com/en-us/azure/search/retrieval-augmented-generation-overview">fundamentals and benefits of RAG</a>. If not, I recommend checking out some foundational resources before diving in. While this guide is based on Azure AI Search, the principles apply to other technologies as well.</p><p>To keep things practical and easy to follow, each step will be structured into two parts:</p><ul><li>Concept &amp; Approach — What needs to be done and why it matters</li><li>Real-World Scenario — A concrete example illustrating the process in action</li></ul><p>By following along, you won’t just learn how to build a RAG application — you’ll learn how to make it truly useful in production. Let’s get started! 🚀</p><h3>Steps Overview</h3><ul><li><a href="#3765">Step1: Clarify the Requirements</a></li><li><a href="#6deb">Step2: Assess the input data</a></li><li><a href="#233f">Step3: Define Accuracy Metrics</a></li><li><a href="#0b2a">Step4: Design the Application Architecture and Azure AI Search Schema</a></li><li><a href="#a01f">Step5: Implement the Application</a></li><li><a href="#7c57">Step6: Import Data into Azure AI Search</a></li><li><a href="#e613">Step7: Execution</a></li><li><a href="#63bf">Step8: Analyze Results and Optimize</a></li></ul><h3>Step1: Clarify the Requirements</h3><h4>Concept &amp; Approach</h4><p>Before jumping into implementation, it’s crucial to define what your RAG application should accomplish. A well-defined goal ensures the solution is practical and delivers real value.</p><p>For example, if employees struggle to find internal documents, a RAG-powered system can help — but what exactly should it do? Should it only retrieve relevant files, or should it also generate concise AI summaries? Should users access the original files, or should they primarily interact with extracted content and AI-generated summaries?</p><p>Clarifying these requirements upfront prevents wasted effort and ensures the solution aligns with actual needs.</p><h4>Real-World Scenario</h4><p>For this guide, we’ll assume that both the user queries and documents are in the same language. Our goal is to enable users to:</p><ol><li>Receive AI-generated summaries derived from the most relevant documents.</li><li>View detailed information about the relevant documents, including their file names and locations.</li><li>Click on hyperlinks to directly access the relevant documents.</li></ol><p><strong>Example Query:</strong></p><p><em>How do I apply for reimbursement for an overseas business trip?</em></p><p><strong>Example AI-Generated Summary:</strong></p><p><em>Submit an Expense Report with receipts, an Approval Form signed by your manager, and a Travel Itinerary. Ensure expenses comply with company policy. Attach invoices and proof of payment. Submit through the expense system or finance department. Keep copies for records and audits.</em></p><p><em>Related Files (ranked by relevance):<br>- Expense_Report_Template.xlsx<br>- Business_Trip_Approval_Form.pdf<br>- Travel_Itinerary_Sample.docx</em></p><p>By setting clear expectations, we ensure our RAG application delivers real business value, rather than just being a fancy search tool.<br>Now, let’s dive into making this work! Below is an image to help you visualize the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zg5aB2gQjeNUmWE4_olyNw.png" /><figcaption>generated by <a href="http://claude.ai/">Claude</a></figcaption></figure><h3>Step2: Assess the input data</h3><h4>Concept &amp; Approach</h4><p>Before adding document content to a search service (e.g., Azure AI Search), it’s essential to understand and assess the input data. This helps in designing an efficient ingestion process and avoiding unexpected challenges. Key factors to consider include:</p><p><strong>File Types &amp; Sizes</strong></p><ul><li>What types of documents will the system process? PDFs, Word files, Excel spreadsheets?</li><li>What are the average and maximum file sizes? This helps estimate processing time and storage needs.</li></ul><p><strong>Chunking &amp; Overlap Strategy</strong></p><ul><li>Rather than diving into specific chunking &amp; overlap strategies here, I encourage you to research best practices that fit your data and use case.</li></ul><p><strong>Data Extraction Requirements</strong></p><ul><li>Do files contain images with embedded text? If so, should OCR (Optical Character Recognition) be used? (e.g., Azure Document Intelligence)</li><li>Should images themselves be analyzed using vision models?</li></ul><p><strong>Extraction Tools</strong></p><ul><li>Should we use open-source libraries?</li><li>Or opt for cloud-based solutions like Azure Document Intelligence.</li></ul><p><strong>Preprocessing Needs</strong></p><ul><li>Are there unsupported formats requiring conversion before ingestion?</li></ul><h4>Real-World Scenario</h4><p>For this guide, let’s assume our input dataset consists of:</p><p><strong>File Types &amp; Sizes</strong></p><p>You can estimate the time required to process all file contents into Azure AI Search by considering the number of files, as well as the TPM/RPM and token limitations of the embedding model. This will help determine the application’s release date.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/556f8ca96013d871701de321001d9d76/href">https://medium.com/media/556f8ca96013d871701de321001d9d76/href</a></iframe><p><strong>Chunking &amp; Overlap Strategy</strong></p><p>For Excel, our chunking strategy is based on tokens for each sheet. Depending on the use case, you can also treat each row as a separate chunk.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67d53ec3912a586c4ffc3cdc274bcdf7/href">https://medium.com/media/67d53ec3912a586c4ffc3cdc274bcdf7/href</a></iframe><p><strong>Data Extraction Requirements</strong></p><ul><li>Extract text from images using OCR</li></ul><p><strong>Extraction Tools</strong></p><ul><li>Since costs are acceptable, we’ll use Azure Document Intelligence</li></ul><p><strong>Preprocessing Needs</strong></p><ul><li>No special file format conversions required</li></ul><p>By thoroughly assessing input data before implementation, we can ensure a smooth document processing for our RAG application.<br>Now that we have a clear understanding of our data, let’s move on to the next step!</p><h3>Step3: Define Accuracy Metrics</h3><h4>Concept &amp; Approach</h4><p>After defining requirements and preparing data, it’s crucial to establish how to evaluate the accuracy of your RAG system. Without clear metrics, you won’t know if the system is performing well or needs improvements.</p><p><strong>Key Considerations</strong></p><ul><li>What defines a “correct” result? For example:<br>・ For relevant documents, should the top 3 or top 10 search results contain the right document?<br>・ For summarization, how do we judge its accuracy?</li><li>Granularity of Evaluation — Should accuracy be measured at the document level or at a more detailed level (e.g., page, section, or spreadsheet sheet)?</li><li>Acceptable Accuracy Rate — What percentage of correct results is considered good enough for production use?</li></ul><h4>Real-World Scenario</h4><p>To evaluate our RAG system, we define accuracy criteria as follows:</p><ul><li>Relevant Documents — A search result is considered correct if the top 10 retrieved results contain the expected document and location.</li><li>Summarization — A summary is considered correct if it covers the key expected points.</li><li>Acceptable Accuracy Rate — We initially set the target accuracy at:<br>・60% for relevant document retrieval<br>・50% for summarization</li></ul><p>To systematically evaluate performance, prepare an Excel sheet like the one shown below. This structured approach helps assess search and summarization accuracy:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f73aa9738c16bbf170b6b605899515e/href">https://medium.com/media/4f73aa9738c16bbf170b6b605899515e/href</a></iframe><ul><li>User Query — Sample questions users might ask.</li><li>Retrieved File Name — The filename of the retrieved document.</li><li>Retrieved Position — The location of the retrieved content (e.g., page number for PDFs, sheet name for Excel files).</li><li>Retrieved Content — The specific content retrieved from the document.</li><li>Expected File Name — The correct file that should be retrieved.</li><li>Expected Position — The correct location of the expected content.</li><li>Summarization Result — The AI-generated summary.</li><li>Expected Summarization Result — Since AI-generated summaries may vary, define key points that should be included to determine correctness.</li><li>Is Retrieved Search Result Correct? — Yes/No.</li><li>Is Summarization Correct? — Yes/No.</li><li>Summarization Result Evaluation — If incorrect, provide an explanation to help analyze the issue and identify potential improvements.</li></ul><p>By defining clear accuracy metrics, you ensure your RAG system is measurable, reliable, and continuously improvable.</p><h3>Step4: Design the Application Architecture and Azure AI Search Schema</h3><h4>Concept &amp; Approach</h4><p><strong>Architecture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*obAw702rgHeWYJpRiCMBwQ.png" /><figcaption>RAG Application Architecture</figcaption></figure><p>A typical RAG application consists of:</p><ul><li>Search Service — Such as Azure AI Search.</li><li>AI Service — Such as Azure OpenAI.</li><li>OCR Service — Such as Azure Document Intelligence.</li><li>Frontend Server — Accepts user queries and displays search results &amp; summaries.</li><li>Backend Server — Processes queries, interacts with Azure AI Search &amp; GPT and Embedding models.</li><li>Batch Processing Server — Extracts document content, and interacts with Embedding model, and adding data to Azure AI Search. Depends on needs, documents be imported manually, periodically, or automatically as soon as they’re updated? If updates are frequent, an automated ingestion pipeline is essential.</li><li>Storage — The place where documents be stored (e.g., SharePoint, local servers, or other cloud storage). Sometime it is also related to how you are going to maintain the documents.</li><li>Database — In the initial stage, you might not need this. However, depending on the requirements, you can add a database to store the extracted content from the OCR model, reducing costs when uploading the same document to another Azure AI Search index. You can also use the database to save users’ search histories.</li></ul><p><strong>Designing Azure AI Search Index Schema</strong></p><p>Think of Azure AI Search as similar to a relational database, which can help you imagine its functionality. Its index just like table. Its fields just like columns ! When designing the schema, you first need to know what properties we should set for each field:</p><ul><li>Retrievable: Determines which fields are returned in search results. Follow the principle of least privilege — retrieve only necessary fields in production but enable all fields during development for debugging.</li><li>Searchable: Defines which fields are indexed for text search. Set only relevant fields as searchable.</li><li>Filterable: Enables filtering on certain fields. Useful for optimizing search results.</li><li>Depending on your needs, you may require Sortable and Facetable properties.</li></ul><p><strong>Important Considerations</strong></p><ul><li>Search order is consistent for the same query unless new documents are added.</li><li>Filterable and searchable settings cannot be changed after index creation — careful planning is required.</li><li>Other search approaches, such as hybrid search, can also be explored for optimization.</li></ul><h4>Real-World Scenario</h4><p><strong>Architecture</strong></p><ul><li>For Azure OpenAI, we need both a GPT model and an embedding model. The embedding model is used during data ingestion to generate vector representations for storage in Azure AI Search. It is also used to convert queries into vectors for performing vector searches.</li><li>Documents are stored in SharePoint and maintainer will update the files to the latest. It also means that there are not the same file for different version.</li><li>An automated import process runs daily to keep content up to date.</li></ul><p><strong>Azure AI Search Index Schema</strong></p><p>We assume Azure AI Search index’ fields contains:</p><ul><li>file_name: <br>・name of the file<br> ・Retrievable-true, Searchable-false, Filterable-false</li><li>chunk_content<br>・real content in the chunk<br>・Retrievable-true, Searchable-true, Filterable-false</li><li>chunk_content_position<br>・location in the file like page or sheet_name<br>・Retrievable-true, Searchable-false, Filterable-false</li><li>chunk_content_vector<br>・vectorized result for chunk content<br>・Retrievable-true, Searchable-true, Filterable-false</li><li>file_link<br>・The original file link for the end-use to browse<br>・Retrievable-true, Searchable-false, Filterable-false</li><li>document_category<br>・Customized for filter, we asuume the content will be some category of documents. It’s one of the optimized strategy when accuracy is not enough.<br>・Retrievable-true, Searchable-false, Filterable-true</li></ul><p>Below is an illustration that differs from the fields I mentioned earlier, but it will help you easily understand the properties of an Azure AI Search index field. The image is referenced from the <a href="https://devblogs.microsoft.com/dotnet/vector-data-qdrant-ai-search-dotnet/">Microsoft Dev Blogs</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nhbp0-OjTaj5yVNk_sr2gg.png" /><figcaption>Example of Azure AI Search Index Fields</figcaption></figure><h3>Step5: Implement the Application</h3><p>This step is not covered in detail, as many online tutorials provide code examples for implementing RAG applications.</p><h3>Step6: Import Data into Azure AI Search</h3><h4>Concept &amp; Approach</h4><p>Start by running the batch processing server to handle data ingestion. Consider implementing error handling to manage document upload failures. If a document fails to upload, determine a strategy to recover from partial uploads and ensure data consistency.</p><h4>Real-World Scenario</h4><p>To keep things simple, if a document fails during the upload process and only part of it is ingested, we should delete all related data and reprocess the document from scratch.</p><p>By carefully designing the strategy for updating the data in the Azure AI Search index, we ensure our RAG system stays up to date, remains efficient, and meets user needs.</p><h3>Step7: Execution</h3><h4>Concept &amp; Approach</h4><p>Refer back to the accuracy metrics defined in Step 3 and use a predefined Excel sheet to execute the evaluation. You can perform this manually or automate it with a script.</p><h4>Real-World Scenario</h4><p>If executed manually, the process would follow these steps:</p><ol><li>Enter sample queries into the RAG application.</li><li>Retrieve both the search results and the summarization output from the RAG application.</li><li>Record these results in the Excel sheet.</li><li>Compare them with the expected answers.</li><li>Calculate accuracy rates based on the recorded data.</li></ol><h3>Step8: Analyze Results and Optimize</h3><h4>Concept &amp; Approach</h4><p>Once we determine the accuracy rates, we can decide whether further optimization is needed or if we can expand access to more users to collect feedback. At the same time, we should analyze incorrect results to identify possible causes and optimize the system accordingly.</p><h4>Real-World Scenario</h4><p>Below are some common issues that may lead to incorrect responses:</p><p><strong>Search Result Issues</strong></p><ul><li>Too many irrelevant documents: If the search service contains excessive noise, it may dilute relevant results.</li><li>Ambiguous queries: Users may need guidelines on how to phrase better questions.</li><li>Chunk size &amp; overlap tuning: Adjusting these parameters can improve retrieval accuracy but requires re-ingesting data, which can be costly.</li></ul><p><strong>Summarization Issues</strong></p><ul><li>Prompt engineering — Refining the prompts sent to the generative AI model can enhance summarization quality. Using structured prompts with a fixed template often yields better results.</li><li>Excessive search results passed to Azure OpenAI: Passing too many search results to Azure OpenAI can sometimes degrade the answer quality. If search result accuracy is sufficient, we can fine-tune the number of top results passed to Azure OpenAI to improve summarization output.</li></ul><h3>Conclusion</h3><p>Building a useful RAG application extends beyond technical implementation. Key considerations include:</p><ul><li>Document maintenance: Ensure the dataset remains relevant and up to date. The responsible team should update source documents regularly.</li><li>Long-term sustainability: Implement a robust feedback loop and continuous refinement process.</li></ul><p>By focusing on usability and iterative improvements, your RAG application can remain effective and valuable over time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6cf50676e37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[工程師日程] Code Review程式碼審查實踐要點]]></title>
            <link>https://flytoleisure.medium.com/%E5%B7%A5%E7%A8%8B%E5%B8%AB%E6%97%A5%E7%A8%8B-code-review%E7%A8%8B%E5%BC%8F%E7%A2%BC%E5%AF%A9%E6%9F%A5%E5%AF%A6%E8%B8%90%E8%A6%81%E9%BB%9E-aa8cb8265b46?source=rss-13aaacbd0f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa8cb8265b46</guid>
            <category><![CDATA[code-review-checklist]]></category>
            <category><![CDATA[daily-software-engineer]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[pull-request-reviews]]></category>
            <category><![CDATA[code-review]]></category>
            <dc:creator><![CDATA[Leisure Rife]]></dc:creator>
            <pubDate>Sun, 28 Jul 2024 14:27:34 GMT</pubDate>
            <atom:updated>2024-07-28T14:27:34.052Z</atom:updated>
            <content:encoded><![CDATA[<h3>[工程師日程] Code Review程式碼審查要點</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*0b29RrA4e7baVoMOa7XRvA.png" /><figcaption><a href="https://www.canva.com/join/zyj-znl-nfv">canva</a></figcaption></figure><p>本篇文章屬個人見解，若有錯誤部分或不同見解，請不吝指教</p><h3>概要</h3><p>工程師日常生活中除了寫Code、設計架構等等之外，還有很重要的其中一環就是Review團隊成員的程式碼，也就是Code Review。</p><p>那Code Review的時候，我們主要需要Review哪些要點呢？以下將以Pull Request本身觀點及程式碼觀點來做說明。</p><h3>Pull Request本身觀點</h3><h4>Pull Request本身所含資訊是否足夠</h4><p>Pull Request本身裡面所含的資訊，是否足夠能讓Reviewer能夠理解這個Pull Request所要新增的功能或是所要解決的問題。</p><p>個人建議使用Template來規範，這樣成員發Pull Request的時候，自動就有Template，提出者就照個Template填好資料即可。正常內容會包含：主旨、修改前後畫面截圖、相關連結等等。</p><p>Github Template範本可參考：<a href="https://github.com/FlyRayTsou/template-pull-request/blob/v1.0.0/.github/PULL_REQUEST_TEMPLATE.md">https://github.com/FlyRayTsou/template-pull-request/blob/v1.0.0/.github/PULL_REQUEST_TEMPLATE.md</a></p><p>延伸閱讀：<a href="https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository">Creating a pull request template for your repository</a></p><h4>Pull Request所包含修正的內容是否過多</h4><p>若是一個Pull Request包含的修正內容過多，其實則不方便被Review，原則上一個Pull Request所包含的修正內容以一個主題為主。若包含過多主題則可能會被Reviewer退回，會被要求分割成多個Pull Request再重發一次。</p><h4>Commit資訊</h4><p>每一個Commit的基本上就是要能表達一個完整的意義。有些人會一個一個commit看，來進行Code Review。</p><p>另外，儘管有些公司可能沒有規範commit標題及敘述的記述方式。在有規範commit的記述的前提下，可補充相關參考資訊及採用該commit作法的原因或想法。若需記錄的內容過多則可記錄在對應的專案管理系統的Ticket。</p><h3>程式碼觀點</h3><h4>是否符合需求(meet requirement)：</h4><p>最基本需要確認的是寫的code是否有符合所要需求。Reviewer會從Pull Request的資訊來了解需求，並去Review代碼。</p><p>譬如說今天我們在做一個流程審核系統，我們的需求是有管理者權限的使用者才可以操作審核通過按鈕，那我們則就要確認程式碼的邏輯是否正確。</p><h4>是否好維護(Maintainability)</h4><p>譬如說寫的function是否太大等等，未來是否可以再利用或是擴充，但是要記得不要overdesign，所以要在可預見的未來內的想法。同時也要注意是否有足夠的測試程式碼。</p><h4>是否容易讀(Readability)</h4><p>譬如說變數、函數的命名是否恰當。</p><h4>是否有做好例外處理(Error Handling、Edge Case)</h4><p>像是包含後面幾個例子『是否有針對例外做處理以及是否有想足各種edge case』、『是否有處理multi-thread case』、『關注用到的class是否是thread-safe』。</p><h4>是否為可接受的複雜度(Time Complexity、Space Complexity)</h4><p>譬如說，程式處理邏輯是否會造成高的時間複雜度像是O(N²)。此種情況時可思考，是否可以有辦法可以降低時間複雜度。例如說先整理資料後，再進行邏輯處理的部分，讓時間複雜度可以降低至O(N)。</p><h4>自動化檢查的部分</h4><p>正常會設定CI來自動檢查coding style、測試程式碼是否通過及其他品質檢測（例如：SonarQube）。若有一項沒通過，則代表程式碼可能有問題。需要再次修改後，再次提出。</p><h3>總結</h3><p>寫這篇文章主要是紀錄自己目前做Code Review時，會關注哪些點，在日常工作時，也可以參考這篇文章來做Code Review。</p><p>並且，未來回頭看自己時，也可以比較是否因為成長及經驗的不同，而有了不同的看法。</p><p>最後，Google也有公開他們的<a href="https://google.github.io/eng-practices/review/reviewer/standard.html">Code Review指導原則</a>，有興趣的人也可以去閱讀。</p><h3>文章內的常用單字中英文對照</h3><p>實際工作職場上，每一家公司的內部溝通語言不同，大致上來說就是中文跟英文兩種，以下列出相對應字詞，方便大家對照。</p><ul><li>Code：程式碼、代碼</li><li>Code Review、Pull Request Review、Merge Request Review：代碼審查、程式碼審查</li><li>Review：審查</li><li>Reviewer：審查者</li><li>Ticket：工單</li><li>Team member、Member：團隊成員</li><li>Template：範本</li></ul><h3>參考資訊</h3><ul><li>天涯淪落人：Derrick (<a href="https://www.linkedin.com/in/derrick-chung-8oee27/">Linkedin</a>)</li><li><a href="https://enginebai.medium.com/code-review-guidelines-b76a859c377c">https://enginebai.medium.com/code-review-guidelines-b76a859c377c</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa8cb8265b46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Express.js] Setting Up Hot Reloading with Nodemon]]></title>
            <link>https://flytoleisure.medium.com/express-js-setting-up-hot-reloading-with-nodemon-40c2c2f94bc2?source=rss-13aaacbd0f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/40c2c2f94bc2</guid>
            <category><![CDATA[nodemon]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[hot-reload]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Leisure Rife]]></dc:creator>
            <pubDate>Mon, 10 Jun 2024 10:17:46 GMT</pubDate>
            <atom:updated>2025-03-29T05:26:56.081Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*l3VnpfDzgaOjMz8GKX3PNg.png" /><figcaption><a href="https://www.canva.com/join/zyj-znl-nfv">canva</a></figcaption></figure><h3>Express.js Series Articles</h3><ol><li><a href="https://medium.com/@flytoleisure/express-js-i-setting-up-an-express-js-api-with-typescript-from-scratch-a8ac7be70a38">Setting Up an Express.js API with TypeScript from Scratch</a></li><li><a href="https://medium.com/@flytoleisure/express-js-setting-up-coding-conventions-and-transpiling-typescript-into-javascript-322947a9295e">Setting Up Coding Conventions and Transpiling TypeScript into JavaScript</a></li><li><a href="https://medium.com/@flytoleisure/express-js-adding-debug-configuration-and-starting-the-debugger-with-vscode-33f83ea63b69">Adding Debug Configuration and Starting the Debugger with VSCode</a></li><li>(current)Setting Up Hot Reloading with Nodemon</li><li>(To be updated)</li></ol><h3>Preface</h3><p>I am building an API template using Express.js and TypeScript to streamline future development projects. This article is part of a series documenting my progress, helping me deepen my understanding. Your feedback and suggestions are welcome.</p><p>Adding hot reloading can make development more convenient by eliminating the need to manually rebuild when files change. This article will introduce how to set up hot reloading.</p><h3>Step 1: Install Nodemon</h3><p>Install Nodemon as a development dependency.</p><pre>% npm i -D nodemon</pre><ul><li>Ref: <a href="https://nodemon.io/">nodemon</a></li></ul><h3>Step2: Add nodemon.json</h3><p>Create a nodemon.json file with the following content. You can adjust these settings according to your needs.</p><pre>{<br>    &quot;watch&quot;: [&quot;src&quot;],<br>    &quot;ext&quot;: &quot;ts&quot;,<br>    &quot;exec&quot;: &quot;npm run tsx ./src/app.ts&quot;<br>}</pre><h3>Step3: Start the Server with Nodemon</h3><p>You can start the server using the Nodemon command.</p><pre>% npx nodemon<br>npx nodemon<br>[nodemon] 3.1.3<br>[nodemon] to restart at any time, enter `rs`<br>[nodemon] watching path(s): src/**/*<br>[nodemon] watching extensions: ts<br>[nodemon] starting `npm run tsx ./src/app.ts`<br>Example app listening on port 3000</pre><p>If you prefer not to create a nodemon.json file, you can start the server with the following command.</p><pre>% npx nodemon --watch &quot;src/**&quot; --ext &quot;ts&quot; --exec &quot;npx ts-node ./src/app.ts&quot;<br>x tsx ./src/app.ts&quot;<br>[nodemon] 3.1.3<br>[nodemon] to restart at any time, enter `rs`<br>[nodemon] watching path(s): src/**<br>[nodemon] watching extensions: ts<br>[nodemon] starting `npm run tsx ./src/app.ts`<br>Example app listening on port 3000</pre><h3>Step 4: Confirm the Server is Running</h3><p>Navigate to http://localhost:3000/ in your browser. You should see “Hello World!” displayed on the screen.</p><h3>Step 5: Modify a File</h3><p>Change app.ts as shown below and save the file.</p><pre>// ......<br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>    res.send(&#39;Hello World 2024!&#39;)<br>})<br>// .....</pre><p>After saving the file, the terminal will display messages like this.</p><pre>[nodemon] restarting due to changes...<br>[nodemon] starting `npm run tsx ./src/app.ts`<br>Example app listening on port 3000</pre><h3>Step 6: Confirm the Changes</h3><p>Navigate to <a href="http://localhost:3000a">http://localhost:3000</a> again, and it should now display “Hello World 2024!”.</p><h3>Conclusion</h3><p>Now, your server will automatically restart whenever you make changes, saving you the time of manually rebuilding. In future articles, we will add controllers and services and set up relative paths.</p><p>You can find the source code at the link below.</p><p><a href="https://github.com/FlyRayTsou/expressjs-api-template/">https://github.com/FlyRayTsou/expressjs-api-template/</a></p><h3>Reference</h3><ul><li>Using ChatGPT to refine the article makes it more natural.</li><li><a href="https://stackoverflow.com/questions/37979489/how-to-watch-and-reload-ts-node-when-typescript-files-change">How to watch and reload ts-node when TypeScript files change</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40c2c2f94bc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Express.js] Adding Debug Configuration and Starting the Debugger with VSCode]]></title>
            <link>https://flytoleisure.medium.com/express-js-adding-debug-configuration-and-starting-the-debugger-with-vscode-33f83ea63b69?source=rss-13aaacbd0f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/33f83ea63b69</guid>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[debugger]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Leisure Rife]]></dc:creator>
            <pubDate>Fri, 07 Jun 2024 13:54:06 GMT</pubDate>
            <atom:updated>2025-03-29T05:24:23.326Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*m9go4TsynKDOvZ4XOm6QZg.png" /><figcaption><a href="https://www.canva.com/join/zyj-znl-nfv">canva</a></figcaption></figure><h3>Express.js Series Articles</h3><ol><li><a href="https://medium.com/@flytoleisure/express-js-i-setting-up-an-express-js-api-with-typescript-from-scratch-a8ac7be70a38">Setting Up an Express.js API with TypeScript from Scratch</a></li><li><a href="https://medium.com/@flytoleisure/express-js-setting-up-coding-conventions-and-transpiling-typescript-into-javascript-322947a9295e">Setting Up Coding Conventions and Transpiling TypeScript into JavaScript</a></li><li>(current)Adding Debug Configuration and Starting the Debugger with VSCode</li><li>(To be updated)</li></ol><h3>Preface</h3><p>I am building an API template using Express.js and TypeScript to streamline future development projects. This article is part of a series documenting my progress, helping me deepen my understanding. Your feedback and suggestions are welcome.</p><p>In the previous articles, we already know how to start our server. However, it will be more useful to start debugger in the real situation. This article will introduce how to set configuration for debugger in VSCode(Visual Studio Code).</p><h3>Step 1: Create Debug Configuration in VSCode</h3><p>Click the Run and Debug icon on the left sidebar, then click create a launch.json file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yR8sW7GQR3L7WJeCHxFVJg.png" /><figcaption>create a launch.json file</figcaption></figure><p>When the input field appears, type Node.js and select the option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g77pXBnSeUI7qlDh4NEZXw.png" /><figcaption>select debugger</figcaption></figure><p>This will generate the launch.json file with the following content.</p><pre>{<br>    // Use IntelliSense to learn about possible attributes.<br>    // Hover to view descriptions of existing attributes.<br>    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387<br>    &quot;version&quot;: &quot;0.2.0&quot;,<br>    &quot;configurations&quot;: [<br>        {<br>            &quot;type&quot;: &quot;node&quot;,<br>            &quot;request&quot;: &quot;launch&quot;,<br>            &quot;name&quot;: &quot;Launch Program&quot;,<br>            &quot;skipFiles&quot;: [<br>                &quot;&lt;node_internals&gt;/**&quot;<br>            ],<br>            &quot;program&quot;: &quot;${workspaceFolder}/src/app.ts&quot;,<br>            &quot;outFiles&quot;: [<br>                &quot;${workspaceFolder}/**/*.js&quot;<br>            ]<br>        }<br>    ]<br>}</pre><h3>Step 2: Adjust tsconfig.json</h3><p>Set sourceMap to true.</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    // ......<br>    &quot;sourceMap&quot;: true,<br>    // ......<br>  }<br>}</pre><h3>Step 3: Build the Project</h3><p>Run the following command to build.</p><pre>% npx tsc</pre><p>This will create a dist folder with the generated app.js.map file.</p><h3>Step 4: Add a Breakpoint</h3><p>Add a breakpoint in app.ts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*wG4kjFewc9v1eUaxfmXaYg.png" /><figcaption>breakpoint in app.ts</figcaption></figure><h3>Step 5: Start the Debugger</h3><p>Click the Run and Debug icon on the left sidebar, then click the green play button next to Launch Program.</p><h3>Step 6: Verify the Breakpoint</h3><p>Navigate to http://localhost:3000/. The debugger should stop at your breakpoint in VSCode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qlU0-2YI5k7rvUxOiHWyKw.png" /><figcaption>stop at breakpoint</figcaption></figure><p>Click the Continuebutton to continue, and you should see “Hello World” successfully. Then, click stop button to stop debugger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*l6set9xx1Jqd8deQ3mjLww.png" /><figcaption>load successfully</figcaption></figure><h3>Step 7: Add tasks.json for Automatic Builds</h3><p>To avoid manually building the project each time before starting the debugger, add a task that runs before launching the debugger. Add a tasks.json file in the .vscode folder with the following content.</p><pre>{<br>    &quot;version&quot;: &quot;2.0.0&quot;,<br>    &quot;tasks&quot;: [{<br>        &quot;label&quot;: &quot;Transpile TypeScript&quot;,<br>        &quot;command&quot;: &quot;npx tsc&quot;,<br>        &quot;type&quot;: &quot;shell&quot;<br>    }]<br>}</pre><h3>Step 8: Adjust launch.json</h3><p>Add &quot;preLaunchTask&quot;: &quot;Transpile TypeScript&quot; to your launch.json.</p><pre><br>{<br>    // ......<br>    &quot;version&quot;: &quot;0.2.0&quot;,<br>    &quot;configurations&quot;: [<br>        {<br>            // ......<br>            &quot;preLaunchTask&quot;: &quot;Transpile TypeScript&quot;<br>        }<br>    ]<br>}</pre><h3>Step 9: Delete dist Folder and Start Debugger Again</h3><p>Delete the dist folder and press the debug button. The dist folder will be recreated.</p><h3>Step 10: Verify Breakpoint again</h3><p>Navigate to http://localhost:3000/ again. The debugger should stop at your breakpoint. Click the play button to continue and see “Hello World” successfully.</p><h3>Conclusion</h3><p>Currently, there are three ways to start our server:</p><ol><li>Start with a TypeScript file using ts-node.</li><li>Start with a JavaScript file using node.</li><li>Start with the debugger.</li></ol><p>In the future, I will introduce how to add hot reloading for development.</p><p>You can find the source code at the link below.</p><p><a href="https://github.com/FlyRayTsou/expressjs-api-template/">https://github.com/FlyRayTsou/expressjs-api-template/</a></p><h3>Reference</h3><ul><li>Using ChatGPT to refine the article makes it more natural.</li><li><a href="https://medium.com/@matteoluigitommasi/setup-the-vscode-debugger-for-a-nodejs-typescript-project-a9c0a5042687">Setup the VSCode debugger for a NodeJS + Typescript project</a></li><li><a href="https://stackoverflow.com/questions/43836861/how-to-run-a-command-in-visual-studio-code-with-launch-json">How to run a command in Visual Studio Code with launch.json</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33f83ea63b69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Express.js] Setting Up Coding Conventions and Transpiling TypeScript into JavaScript]]></title>
            <link>https://flytoleisure.medium.com/express-js-setting-up-coding-conventions-and-transpiling-typescript-into-javascript-322947a9295e?source=rss-13aaacbd0f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/322947a9295e</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[expressjs-api]]></category>
            <category><![CDATA[eslint]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Leisure Rife]]></dc:creator>
            <pubDate>Sun, 02 Jun 2024 04:06:54 GMT</pubDate>
            <atom:updated>2025-03-29T05:23:25.676Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*aiylpKAb2ewfmSPcJTAjZg.png" /><figcaption><a href="https://www.canva.com/join/zyj-znl-nfv">canva</a></figcaption></figure><h3>Express.js Series Articles</h3><ol><li><a href="https://medium.com/@flytoleisure/express-js-i-setting-up-an-express-js-api-with-typescript-from-scratch-a8ac7be70a38">Setting Up an Express.js API with TypeScript from Scratch</a></li><li>(current)Setting Up Coding Conventions and Transpiling TypeScript into JavaScript</li><li><a href="https://flytoleisure.medium.com/express-js-adding-debug-configuration-and-starting-the-debugger-with-vscode-33f83ea63b69">Adding Debug Configuration and Starting the Debugger with VSCode</a></li><li>(To be updated)</li></ol><h3>Preface</h3><p>I am building an API template using Express.js and TypeScript to streamline future development projects. This article is part of a series documenting my progress, helping me deepen my understanding. Your feedback and suggestions are welcome.</p><p>This article is about how to set coding conventions and how to transpile TypeScript into JavaScript.</p><h3>Step1 : Install Coding Convention Library</h3><p>typescript-eslint is a continuously updated library that provides an easy way to configure coding conventions for TypeScript. If you prefer to configure it yourself, you can start with <a href="https://eslint.org/">ESLint</a>.</p><pre>% npm install --save-dev eslint @eslint/js @types/eslint__js typescript typescript-eslint</pre><p>Reference: <a href="https://typescript-eslint.io/getting-started">https://typescript-eslint.io/getting-started</a></p><h3>Step2 : Add Configuration Coding Convention</h3><p>Follow the official typescript-eslint instructions and add eslint.config.js in the root folder. In my case, I will also add ignores for some folders that we don’t need to check for coding conventions.</p><pre>// @ts-check<br>import eslint from &#39;@eslint/js&#39;;<br>import tseslint from &#39;typescript-eslint&#39;;<br><br>export default tseslint.config(<br>    eslint.configs.recommended,<br>    ...tseslint.configs.recommended,<br>    {<br>        ignores: [&#39;node_modules&#39;, &#39;dist&#39;],<br>    }<br>);</pre><h3>Step3 : Update package.json</h3><p>Please add the below configuration in the package.json or you will encounter errors.</p><pre>{<br>  // ......<br>  &quot;type&quot;: &quot;module&quot;,<br>  // ......<br>}</pre><p>More about the type of package.json : <a href="https://nodejs.org/api/packages.html#type">https://nodejs.org/api/packages.html#type</a></p><h3>Step4 : Execute eslint</h3><p>Use ESLint to check the coding convention.</p><pre>% npx eslint .</pre><p>If you don’t add &quot;type&quot;: &quot;module&quot; in Step 3, you will encounter the following error.</p><pre>(node:96806) Warning: To load an ES module, set &quot;type&quot;: &quot;module&quot; in the package.json or use the .mjs extension.<br>(Use `node --trace-warnings ...` to show where the warning was created)<br><br>Oops! Something went wrong! :(<br><br>ESLint: 8.57.0<br><br>expressjs-api-template/eslint.config.js:3<br>import eslint from &#39;@eslint/js&#39;;<br>......</pre><h3>Step5 : Set Typescript Config</h3><p>Please update the below configuration in the tsconfig.json or you will encounter errors.</p><pre>{<br>  &quot;compilerOptions&quot; : {<br>    /* ...... */<br>    &quot;module&quot;: &quot;es6&quot;,<br>    &quot;rootDir&quot;: &quot;./src&quot;,<br>    &quot;outDir&quot;: &quot;./dist&quot;,<br>    /* ...... */<br>  }<br>}</pre><p>More about module of tsconfig.json : <a href="https://www.typescriptlang.org/tsconfig/#module">https://www.typescriptlang.org/tsconfig/#module</a></p><h3>Step6 : Transpile and Execute</h3><pre>% npx tsc           <br>% node dist/app.js</pre><p>If you do not set &quot;module&quot;: &quot;es6&quot;, you will face the following error.</p><pre>% npx tsc<br>% node dist/app.js<br>file:///Users/rayt/expressjs-api-template/dist/app.js:5<br>Object.defineProperty(exports, &quot;__esModule&quot;, { value: true });<br>                      ^<br><br>ReferenceError: exports is not defined in ES module scope<br>This file is being treated as an ES module because it has a &#39;.js&#39; file extension and &#39;/Users/rayt/expressjs-api-template/package.json&#39; contains &quot;type&quot;: &quot;module&quot;. To treat it as a CommonJS script, rename it to use the &#39;.cjs&#39; file extension.<br>    at file:///Users/rayt/expressjs-api-template/dist/app.js:5:23<br>    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)<br><br>Node.js v19.1.0</pre><p>If you do not set ts-node esm, you will face the following error. If you tried to execute by typescript file.</p><pre>% npx ts-node ./src/app.ts<br>TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension &quot;.ts&quot; for /Users/rayt/expressjs-api-template/src/app.ts<br>    at new NodeError (node:internal/errors:393:5)<br>    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:75:9)<br>    at defaultGetFormat (node:internal/modules/esm/get_format:114:38)<br>    at defaultLoad (node:internal/modules/esm/load:81:20)<br>    at nextLoad (node:internal/modules/esm/loader:161:28)<br>    at ESMLoader.load (node:internal/modules/esm/loader:594:26)<br>    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:446:22)<br>    at new ModuleJob (node:internal/modules/esm/module_job:64:26)<br>    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:469:17)<br>    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:423:34) {<br>  code: &#39;ERR_UNKNOWN_FILE_EXTENSION&#39;<br>}</pre><h3>Conclusion</h3><p>There are two ways to start the application:</p><pre>% npx tsc           <br>% node dist/app.js<br>Example app listening on port 3000<br><br>% npm run tsx ./src/app.ts<br>Example app listening on port 3000</pre><p>You can find the source code at the link below.</p><p><a href="https://github.com/FlyRayTsou/expressjs-api-template/">https://github.com/FlyRayTsou/expressjs-api-template/</a></p><h3>Reference</h3><ul><li>Using ChatGPT to refine the article makes it more natural.</li><li>What is @ts-check：<a href="https://blog.manaten.net/entry/ts-check-for-legacy">https://blog.manaten.net/entry/ts-check-for-legacy</a></li><li>What is ts-node esm：<a href="https://qiita.com/nyanchu/items/82903e0463fa9d558639">https://qiita.com/nyanchu/items/82903e0463fa9d558639</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=322947a9295e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Express.js] Setting Up an Express.js API with TypeScript from Scratch]]></title>
            <link>https://flytoleisure.medium.com/express-js-i-setting-up-an-express-js-api-with-typescript-from-scratch-a8ac7be70a38?source=rss-13aaacbd0f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8ac7be70a38</guid>
            <category><![CDATA[node]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Leisure Rife]]></dc:creator>
            <pubDate>Wed, 29 May 2024 13:00:21 GMT</pubDate>
            <atom:updated>2025-03-29T05:13:43.209Z</atom:updated>
            <content:encoded><![CDATA[<p>Last updated: March 29th, 2025</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*Gbwr9DgTuZJITDgs23vgNA.png" /><figcaption><a href="https://www.canva.com/">Canva</a></figcaption></figure><h3>Express.js Series Articles</h3><ol><li>(current)Setting Up an Express.js API with TypeScript from Scratch</li><li><a href="https://medium.com/@flytoleisure/express-js-setting-up-coding-conventions-and-transpiling-typescript-into-javascript-322947a9295e">Setting Up Coding Conventions and Transpiling TypeScript into JavaScript</a></li><li><a href="https://flytoleisure.medium.com/express-js-adding-debug-configuration-and-starting-the-debugger-with-vscode-33f83ea63b69">Adding Debug Configuration and Starting the Debugger with VSCode</a></li><li>(To be updated)</li></ol><h3>Preface</h3><p>I am building an API template using Express.js and TypeScript to streamline future development projects. This article is part of a series documenting my progress, helping me deepen my understanding. Your feedback and suggestions are welcome.</p><p>This article is about how to start your Express.js project.</p><h3>Prerequisite</h3><p>Ensure you have Node.js and npm installed. If you use macOS, I recommend using nvm (Node Version Manager) for managing Node.js versions efficiently.</p><pre>## MacOS Version: Sonoma 14.3.1<br>## Below is my nvm and node version<br>% nvm -v<br>0.39.3<br>% node -v<br>v22.3.0<br>% npm -v<br>10.8.1</pre><p>You can find installation instructions for nvm, Node.js, and npm online.</p><h3>Step 1 Create a Folder for the API</h3><pre>% mkdir myapi<br>% cd myapi</pre><h3>Step2 add .gitignore</h3><p>Create a .gitignore file in the root folder to exclude node-specific files. You can refer to these resources as below.</p><ul><li><a href="https://github.com/github/gitignore/blob/main/Node.gitignore">GitHub Node.gitignore</a></li><li><a href="https://www.toptal.com/developers/gitignore">Toptal Node.gitignore</a></li></ul><h3>Step3 Initialize package.json</h3><p>Run the following command with -y to create a package.json file with skiping the questionnaire altogether and using default values.</p><pre>myapi% npm init -y</pre><h3>Step4 Install Necessary Packages and Adjust package.json</h3><p>Install Express:</p><pre>myapi% npm i express</pre><p>Install TypeScript and type definitions for Express and tsx as development dependencies:</p><pre>myapi% npm i -D typescript @types/express tsx</pre><p>Modify your package.json to include the tsx script:</p><pre>{<br>  // omitted for brevity<br>  &quot;scripts&quot;: {<br>    &quot;tsx&quot;: &quot;tsx&quot;<br>    // omitted for brevity<br>  }<br>  // omitted for brevity<br>}</pre><p>Note:</p><ul><li>npm i is shorthand for npm install.</li><li>I chose tsx instead of ts-node because ts-node requires more configuration effort.</li></ul><h3>Step5 Initialize tsconfig.json</h3><p>Create a TypeScript configuration file:</p><pre>myapi% npx tsc --init</pre><p>You can also find best practices for tsconfig.json online, such as in <a href="https://tduyng.medium.com/essential-tsconfig-json-options-you-should-use-3187af924221">this</a>.</p><h3>Step6 Add the Entry File</h3><p>Create an app.ts file inside the src folder for starting the server:</p><pre>import express, { Express } from &quot;express&quot;<br><br>const app: Express = express()<br>const port: number = 3000<br><br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>    res.send(&#39;Hello World!&#39;)<br>})<br><br>app.listen(port, () =&gt; {<br>    console.log(`Example app listening on port ${port}`)<br>})</pre><h3>Step6 Execute</h3><p>Start the server and listen on port 3000 for connections using:</p><pre>myapi% npm run tsx ./src/app.ts</pre><p>You should see the message:</p><pre>Example app listening on port 3000</pre><h3>Step7 Check the Result in the Browser</h3><p>Open your browser and navigate to http://localhost:3000. You should see &quot;Hello World!&quot; displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*l6set9xx1Jqd8deQ3mjLww.png" /><figcaption>localhost:3000</figcaption></figure><h3>Conclusion</h3><p>This is the first step in setting up an Express.js API with TypeScript. Future articles will cover topics such as hot-reloading, debugging, coding standards (eslint), relative paths, and transpiling TypeScript files to JavaScript. Stay tuned for more updates!</p><p>You can find the Express.js source code at the link below.</p><p><a href="https://github.com/FlyRayTsou/expressjs-api-template/">https://github.com/FlyRayTsou/expressjs-api-template/</a></p><h3>Reference</h3><ul><li>Using ChatGPT to refine the article makes it more natural.</li><li><a href="https://docs.npmjs.com/cli/v7/commands/npm-init">npm init reference</a></li><li><a href="https://docs.npmjs.com/cli/v7/commands/npm-install">npm install reference</a></li><li><a href="https://www.dhiwise.com/post/package-management-devdependencies-vs-dependencies">depencies vs devDependencies</a></li><li><a href="https://docs.npmjs.com/cli/v8/commands/npx">npx</a></li><li><a href="https://www.typescriptlang.org/docs/handbook/compiler-options.html">tsc</a></li><li><a href="https://github.com/privatenumber/tsx">tsx</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8ac7be70a38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Scrum] How to pass PSD(Professional Scrum Developer)]]></title>
            <link>https://flytoleisure.medium.com/scrum-how-to-pass-psd-professional-scrum-developer-5cc665f8abf9?source=rss-13aaacbd0f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cc665f8abf9</guid>
            <category><![CDATA[certified-scrum-developer]]></category>
            <category><![CDATA[scrumorg]]></category>
            <category><![CDATA[scrum-agile]]></category>
            <category><![CDATA[scrum]]></category>
            <category><![CDATA[scrum-guide]]></category>
            <dc:creator><![CDATA[Leisure Rife]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 13:18:04 GMT</pubDate>
            <atom:updated>2023-07-17T13:18:04.647Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>（Earned date：2023/05）</p><p><a href="https://www.scrum.org/assessments/professional-scrum-developer-certification">The Professional Scrum Developer (PSD)</a> certification validates your knowledge of how to deliver quality software using the Scrum framework while working in Scrum Teams including the application of modern Agile and DevOps practices. Earning PSD proves that you have demonstrated an understanding of the fundamentals of applying the Scrum framework as it applies to software development.</p><p>I took about 10 ~ 15 hour to prepare PSD certification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*k0X3ebIyH-sm1RKCGp7HLA.png" /><figcaption><a href="https://www.canva.com/">canva</a></figcaption></figure><h3>Intended audience</h3><ul><li>Who want to earn PSD(Professional Scrum Developer) certification</li><li>Who are interested in Scrum</li></ul><h3>Should earn PSD certification ?</h3><p>I still not sure whether this certification will help me in my career path.</p><p>It is a good chance to learn Scrum. In the meanwhile, if you think the certification fee is acceptable for you, you can try it.</p><h3>First step</h3><p>Read through the <a href="https://www.scrum.org/resources/scrum-guide">Scrum Guide</a> on Scrum.org. Then, try <a href="https://www.scrum.org/open-assessments/scrum-developer-open">mock exams</a>.</p><h3>Second step</h3><p>I would recommend practicing with both the <a href="https://www.scrum.org/open-assessments/scrum-developer-open">Scrum Developer Open</a> and <a href="https://www.scrum.org/open-assessments/scrum-open">Scrum Open</a> mock exams, aiming to complete each within ten minutes and achieve an accuracy rate of over 95%. Afterward, you can focus on strengthening your understanding of the questions you answered incorrectly.</p><p>Personally, I am not familiar with Test-Driven Development (TDD) and Behavior-Driven Development (BDD) so I spent some time to learn more about that.</p><h3>Third step</h3><p>The course <a href="https://www.udemy.com/course/professional-scrum-developer-i-psd-i-practice-exams/">Professional Scrum Developer I (PSD I) Practice Tests Exams</a> on Udemy is very helpful as it similar the actual exam.<br>※This course explicitly states that it is not an exam dump.<br>※Reading books about Scrum will also be helpful in preparing for the exam.</p><h3>Conclusion</h3><p>During the actual exam, you will be required to answer 80 questions in 60 minutes. I find it quite challenging because there isn’t much time for thoughtful consideration. Furthermore, the multiple-choice options often present difficult choices. Therefore, if there are questions regarding fundamental Scrum knowledge, it is crucial to seize the opportunity.</p><p>Even if you do not intend to earn Scrum-related qualifications, reading through the Scrum Guide can still be beneficial. If you have the time, I highly recommend giving it a thorough read.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cc665f8abf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Scrum] PSD(Professional Scrum Developer)證書取得經驗談]]></title>
            <link>https://flytoleisure.medium.com/scrum-psd-professional-scrum-developer-%E8%AD%89%E6%9B%B8%E5%8F%96%E5%BE%97%E7%B6%93%E9%A9%97%E8%AB%87-cea50c5aafea?source=rss-13aaacbd0f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/cea50c5aafea</guid>
            <category><![CDATA[scrum-guide]]></category>
            <category><![CDATA[scrum]]></category>
            <category><![CDATA[professional-scrum]]></category>
            <category><![CDATA[certified-scrum-developer]]></category>
            <category><![CDATA[scrum-agile]]></category>
            <dc:creator><![CDATA[Leisure Rife]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 12:39:53 GMT</pubDate>
            <atom:updated>2023-07-17T13:19:53.404Z</atom:updated>
            <content:encoded><![CDATA[<h3>概要</h3><p>（取得PSD時間：2023/05）</p><p><a href="https://www.scrum.org/assessments/professional-scrum-developer-certification">PSD(Professional Scrum Developer)</a>認證是指擁有使用Scrum框架去開發良好品質的軟體所需的知識證明。簡單來說就是確認您對於Scrum中Developer需扮演的角色、所需的知識及Scrum本身是否熟悉。</p><p>總共準備時間大約需10~15個小時。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*xZMfLZep_EjhrpWBdlLGew.png" /><figcaption><a href="https://www.canva.com/">canva</a></figcaption></figure><h3>本文閱讀對象</h3><ul><li>想要取得 PSD(Professional Scrum Developer) 證書的人</li><li>對於Scrum有興趣的人</li></ul><h3>是否需要取得證書</h3><p>有這張證書對於未來職涯是否會有幫助，我自己還沒有肯定的答案。</p><p>但我覺得如果你對申請證書的費用不太在意，反正已經學習了Scrum相關知識，順便取得證書也是不錯。</p><h3>第一步</h3><p>首先先把Scrum.org裡的<a href="https://www.scrum.org/resources/scrum-guide">Scrum Guide</a>讀過一遍。然後試試<a href="https://www.scrum.org/open-assessments/scrum-developer-open">模擬測驗</a>。</p><p>雖然也有<a href="https://scrumguides.org/download.html">中文版的Scrum Guide</a>，但考試是只有英文，所以還是建議讀英文的。</p><h3>第二步</h3><p>建議你可以練到<a href="https://www.scrum.org/open-assessments/scrum-developer-open">Scrum Developer Open</a>跟<a href="https://www.scrum.org/open-assessments/scrum-open">Scrum Open</a>的兩個模擬測驗都可以在十分鐘內完成，以及可以達到正解95%以上。</p><p>接著，可以再去針對自己錯的題目，去加強學習。像我自己比較不熟的地方是TDD(Test-Driven Development)跟BDD(Behavior-driven development)。</p><h3>第三步</h3><p>Udemy的<a href="https://www.udemy.com/course/professional-scrum-developer-i-psd-i-practice-exams/">Professional Scrum Developer I (PSD I) Practice Tests Exams</a>的課程，我覺得跟實際考試時的出題方向很類似，很有幫助。<br>※這個課程有註明說不是Exam Dump。<br>※閱讀Scrum相關書籍也會有幫助</p><h3>結論</h3><p>實際考試時，要在60分鐘之內回答80題。我覺得是蠻有難度的，因為沒有很多時間可以讓你去思考。</p><p>同時，選擇題裡很常會有很難抉擇的選項出現，所以如果有出現Scrum基本知識題目的話，請一定要把握住。</p><p>最後，即使如果你沒有打算要取得Scrum相關資格的話，去讀一遍Scrum Guide也會有幫助。有時間的話，建議大家讀讀看。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cea50c5aafea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AZ-900證書取得經驗談]]></title>
            <link>https://flytoleisure.medium.com/az-900%E8%AD%89%E6%9B%B8%E5%8F%96%E5%BE%97%E7%B6%93%E9%A9%97%E8%AB%87-71b2aa713f39?source=rss-13aaacbd0f66------2</link>
            <guid isPermaLink="false">https://medium.com/p/71b2aa713f39</guid>
            <category><![CDATA[az-900-exam]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[az900]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Leisure Rife]]></dc:creator>
            <pubDate>Tue, 02 May 2023 05:55:02 GMT</pubDate>
            <atom:updated>2023-05-02T08:12:56.035Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Azure] AZ-900證書取得經驗談</h3><h3>概要</h3><p>（取得AZ-900時間：2023/04）</p><p>AZ-900 是Azure 基礎知識的測驗，為證明了解雲概念、Azure 服務、Azure 工作負載、Azure 中的安全性和隱私以及 Azure 定價和支持提供的機會。</p><p>我自己工作上會用 Azure 來架網站，但大部分只會用到一部分 Azure 的服務而已。所以我並不是很清楚全部 Azure 到底有哪些服務，而且也不知道加上使用哪些功能或是統合哪些服務會對現在的網站有幫助。</p><p>所以我學習了 Azure 的整體基礎知識，並順便取得了 AZ-900 證書。(我覺得讀英文比較順，所以我是選擇用英文來進行測驗)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Cgel2sXCI7AmgHC-qX7iww.png" /><figcaption><a href="https://www.canva.com/">canva</a></figcaption></figure><h3>本文閱讀對象</h3><ul><li>想要取得 AZ-900 證書的人</li><li>希望學習 Azure 整體基礎知識的人</li></ul><h3>是否需要取得證書</h3><p>我自己覺得如果你對申請證書的費用不太在意，反正已經學習了相關知識，順便取得證書也是不錯。</p><h3>準備</h3><h4>學習方法</h4><p>首先，建議先到微軟的培訓網站上，閱讀關於 ”<a href="https://learn.microsoft.com/zh-tw/certifications/exams/az-900/">測驗AZ-900: Microsoft Azure Fundamentals 的自學型</a>” 的內容，接著嘗試去考模擬測驗，最後去藉由錯的題目去加強相關知識。</p><p>整體而言，有點像在學校上課的感覺，所以建議可以學的時候，順便實際去操作 Azure Portal ，這樣會比較容易記起來。</p><p>最重要的是，了解何時應該使用什麼服務，以及可以解決什麼問題。如果主要的概念有理解的話，實際上測驗就不會太難。</p><p>譬如說：</p><ul><li>如果你同時有公司私人機台和公有雲的情況下，您用什麼服務就可以更輕鬆的一起管理你的 Infra ？</li><li>你可以用什麼功能讓你更容易管理成本和預算？</li></ul><h4>學習時間</h4><p>微軟的培訓網站中提供了每個項目的學習預估時間，但我應該總共大概花了 30 個小時。實際上，我覺得應該 20 個小時應該就夠了。</p><p>所以我覺得學習和模擬測驗總共花的時間是大約微軟預估的學習時間的4倍。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73e1a9a4eb5c933386c989cb63b3fc51/href">https://medium.com/media/73e1a9a4eb5c933386c989cb63b3fc51/href</a></iframe><h4>模擬測驗</h4><p>首先先到 <a href="https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RWSRk3">AZ-900: Microsoft Azure Fundamentals Sample Questions</a> 去確認測驗中可能有的問題的類型，然後再去考模擬測驗。</p><p>我自己參加的模擬測驗是 Practice Test 和 MeasureUp 。</p><p>難度上來說是 MeasureUp &gt; 實際測驗 &gt;&gt; Practice Test</p><p>Practice Test 比實際測驗容易很多，所以即使通過了 Practice Test，也不要掉以輕心。</p><ul><li><a href="https://learn.microsoft.com/en-us/certifications/exams/az-900/practice/assessment?assessment-type=practice&amp;assessmentId=23">Microsoft Practice Test AZ-900</a>：免費</li><li><a href="https://www.measureup.com/microsoft-practice-test-az-900-microsoft-azure-fundamentals.html">MeasureUp</a>：收費</li></ul><h3>結論</h3><p>這只是一個基礎的證書，所以不需要過度緊張。即使測驗中有困難的問題，測驗時間還蠻多的，所以會有足夠的時間可以思考。</p><h3>Ref</h3><ul><li><a href="https://learn.microsoft.com/zh-tw/certifications/exams/az-900/">https://learn.microsoft.com/zh-tw/certifications/exams/az-900/</a></li><li><a href="https://learn.microsoft.com/zh-tw/certifications/resources/study-guides/az-900">https://learn.microsoft.com/zh-tw/certifications/resources/study-guides/az-900</a></li><li><a href="https://medium.com/@mesirii/5-tips-for-embedding-tables-in-your-medium-posts-8722f3fc5bf5">https://medium.com/@mesirii/5-tips-for-embedding-tables-in-your-medium-posts-8722f3fc5bf5</a></li></ul><h3>附記</h3><p>我寫這篇文章的時候，是先寫了<a href="https://qiita.com/T-M-H/items/2a29dd38f3de63679334">日文版本</a>，再用ChatGPT幫我翻譯成中文。接著我再去修改讓文章更通順，最後再補上Medium需要的圖片的表格。不過最後大概也是花了45分鐘左右，要再來想想更方便的轉換各語言的方法。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71b2aa713f39" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>