Category: Blog

A Life Woven with Innovation and Vision.

  • 打造高效穩定的現代 Web 應用:Vite、Node.js、TypeScript、Apache、pm2 與 Nginx 的完美協奏

    在這個快速發展的網路世界中,開發高效、穩定且易於維護的 Web 應用程式至關重要。一套優秀的技術棧能夠極大地提升開發效率並確保應用程式的可靠性。今天,我們就來聊聊如何將 Vite、Node.js、TypeScript、Apache、pm2 和 Nginx 這些強大的工具組合起來,打造出令人滿意的現代 Web 應用。

    各司其職,共創美好

    讓我們逐一認識這些技術,並了解它們在整個應用程式生命週期中所扮演的角色:

    • Vite:新一代前端開發體驗的領跑者告別緩慢的傳統打包工具,Vite 以其閃電般的速度和極佳的開發者體驗脫穎而出。它利用原生 ES 模組和 Rollup 的優勢,實現快速的冷啟動、即時熱模組替換(HMR),讓前端開發變得更流暢、更有效率。如果您還在使用傳統的打包工具,強烈建議您試試 Vite,它會顛覆您對前端開發的認知。
    • Node.js:後端開發的強大引擎Node.js 憑藉其非阻塞 I/O 和事件驅動的特性,成為構建高性能、可擴展網路應用程式的理想選擇。它基於 JavaScript 運行時環境,使得前端開發者可以輕鬆地跨足後端,實現全端開發。豐富的 npm 生態系統也為 Node.js 開發者提供了無數的函式庫和工具,加速開發進程。
    • TypeScript:為 JavaScript 注入強大的型別系統隨著應用程式的複雜度不斷增加,JavaScript 的動態型別有時會帶來一些困擾。TypeScript 的出現正是為了解決這個問題。它在 JavaScript 的基礎上增加了靜態型別檢查、介面、泛型等特性,使得程式碼更易於理解、維護和重構,有效減少了運行時錯誤,提升了開發效率和程式碼品質。
    • Apache:傳統而可靠的 Web 伺服器Apache HTTP Server 是世界上最流行的 Web 伺服器之一。它以其穩定性、安全性以及豐富的模組而聞名。雖然在處理高並發方面可能不如 Nginx,但對於許多中小型應用程式或需要特定 Apache 模組的場景來說,它仍然是一個非常可靠的選擇。
    • pm2:Node.js 應用程式的生產環境守護者當我們的 Node.js 應用程式準備部署到生產環境時,pm2 就派上了用場。它是一個強大的進程管理器,可以幫助我們輕鬆地在後台運行 Node.js 應用程式,並提供自動重啟、負載均衡、日誌管理、監控等多種實用功能,確保我們的應用程式穩定運行。
    • Nginx:高效能的反向代理與負載均衡器Nginx 是一個輕量級但功能強大的 Web 伺服器,尤其擅長處理高並發請求。在我們的架構中,Nginx 通常被用作反向代理伺服器。它可以接收來自用戶端的請求,然後將這些請求轉發給後端的 Node.js 應用程式。同時,Nginx 也可以作為負載均衡器,將流量分發到多個 Node.js 實例上,提高應用程式的整體效能和可用性。透過 DNS 的配置,我們可以將域名指向 Nginx 伺服器,再由 Nginx 將請求正確地路由到後端服務。

    協同運作:打造強大的應用程式

    那麼,這些技術是如何協同工作的呢?讓我們來看一個典型的部署流程:

    1. 前端開發 (Vite + TypeScript): 開發者使用 Vite 作為前端開發伺服器,享受快速的開發體驗。TypeScript 的型別檢查確保程式碼品質。最終,Vite 會將前端程式碼打包成優化後的靜態資源。
    2. 後端開發 (Node.js + TypeScript): 後端開發者使用 Node.js 和 TypeScript 構建 API 服務或伺服器端渲染應用程式。
    3. 部署與運行 (pm2): 將後端 Node.js 應用程式部署到伺服器上,並使用 pm2 進行管理。pm2 確保應用程式在崩潰時自動重啟,並方便管理應用程式的生命週期。
    4. 反向代理與流量管理 (Nginx): 在伺服器前端部署 Nginx。Nginx 監聽指定的網域名稱和連接埠(通常是 80 或 443)。當用戶端發送請求時,Nginx 根據配置將請求轉發給後端由 pm2 管理的 Node.js 應用程式。對於前端靜態資源,可以配置 Nginx 直接提供服務,或者將其作為後端服務的一部分。
    5. 可選的 Apache: 在某些情況下,Apache 可能部署在 Nginx 之後,用於處理特定的請求或提供某些特定的功能,例如基於 .htaccess 的配置。但更常見的是,Nginx 作為前端反向代理已經能夠滿足大部分需求。

    高效、穩定、現代化的 Web 開發方案

    Vite、Node.js、TypeScript、Apache、pm2 和 Nginx 的組合提供了一個強大而靈活的現代 Web 應用程式開發和部署方案。Vite 和 TypeScript 提升了前端開發的效率和品質;Node.js 為後端提供了高性能的運行環境;pm2 確保了 Node.js 應用程式在生產環境中的穩定運行;而 Nginx 則作為高效能的反向代理和負載均衡器,保障了應用程式的效能和可用性。

  • Stay Away from These “Warning Sign” Vehicles on the Road

    Stay Away from These “Warning Sign” Vehicles on the Road

    When you’re out driving, it’s not just about following the traffic lights or checking your mirrors. Sometimes, simply observing the condition of the vehicles around you can keep you out of trouble.

    This morning, while I was making a left turn, a beat-up, dirty car almost slammed into me from behind. The car looked like it hadn’t seen a car wash or a mechanic in years—scratches everywhere, dented panels, and a general air of “I don’t care.” If you see a car like that on the road, keep your distance.

    It’s not about judging older cars, but let’s be real—cars that look like they’re falling apart usually have two problems:

    1. The driver tends to be reckless—cutting lanes, ignoring signals, or tailgating.
    2. The vehicle itself may be poorly maintained—worn-out brakes, sketchy tires, or steering issues.

    And that wasn’t even the scariest thing that happened this week.

    Just two days ago, a massive construction crane truck was making a turn about 3 meters away from me. Out of nowhere—BANG—the inner tire exploded. The sound was just like a gunshot at a shooting range. It left my ears ringing and even damaged the asphalt road from the shockwave.

    At that moment, all I could think was: I need to go make an offering at the temple.

    These heavy-duty vehicles, even when operated by pros, are still unpredictable. Their size, weight, and mechanical wear make them high-risk—especially when they’re turning or operating in tight spaces.

    Here’s the takeaway: if you see any of these “warning sign” vehicles, stay far away:

    • Dirty, dented cars that clearly haven’t been maintained.
    • Drivers with erratic behavior—abrupt lane changes, no signals, or constant braking.
    • Large trucks, construction vehicles, or anything that looks like it could squash a car.

    Driving is already full of surprises. But with a little more awareness and space, you might avoid a crash—or at least a major scare.

    Stay safe out there. And hopefully, after this streak of close calls, my luck turns around soon.

  • 路上的「警訊車」:那些你最好離遠一點的車種

    路上的「警訊車」:那些你最好離遠一點的車種

    日常開車上路,除了留心號誌與路況之外,有時候觀察周圍的車輛狀況,也可能救你一命。

    今天早上,我在一個路口準備左轉,後方一輛「切西瓜」式亂鑽的小破車差點撞上我。那台車不但外觀髒兮兮,車身明顯有刮傷、板金凹陷,感覺幾百年沒保養過。這種車,千萬要離它遠一點!

    這不是歧視車齡或老車,而是因為這類車輛通常存在兩種問題:

    1. 駕駛人風險意識低,常見亂切、硬闖行為。
    2. 車況不佳,煞車、轉向、輪胎等都可能不穩定。

    而這幾天的另一次經歷,更讓我決定寫下這篇文章。

    就在前天,一台大型工程吊車從我身旁不到三公尺的距離轉彎,突然「砰」地一聲——內側輪胎爆胎!那聲音跟打靶時的槍聲一樣震耳欲聾,耳朵瞬間幾乎耳鳴。現場還能看到柏油路面被衝擊波震裂。

    我當時只有一個念頭:該去拜拜了。

    這類大型工程車,雖然多數由專業司機操作,但因為車身重、轉彎半徑大,加上有時車況不理想(像這次的爆胎),對周圍車輛和行人來說,都是高風險因素。

    總結一下,如果你在路上看到這些「警訊車」,請自保,離遠一點:

    • 外觀殘破、灰頭土臉,看起來沒什麼在保養的車。
    • 行車行為詭異、猛然加速減速、不打方向燈就變換車道的車。
    • 大型工程車、貨車,尤其在狹窄道路或轉彎處。

    開車本來就充滿不可預測的風險,但多一點觀察,多一點警覺,也許就能少一次擦撞或驚嚇。

    祝大家平安,也祝我最近一連串驚魂過後,能轉個運。

  • Taiwan’s Urban Landscape Disorder

    Taiwan’s Urban Landscape Disorder

    In many areas across Taiwan, sidewalks and roadside spaces are frequently occupied by potted plants, traffic cones, and other private items placed by ground-floor residents. This leads to the privatization of public spaces. Although such behavior disrupts both urban aesthetics and pedestrian access, local governments have long neglected the issue, allowing it to become a normalized part of the everyday streetscape.

    Compared to Japan’s clean and orderly urban scenery, Taiwan’s streets often appear cluttered due to unauthorized placement of items by residents. These private occupations not only obstruct movement but also significantly degrade the visual quality of the city. The longstanding inaction by local governments has turned public spaces—meant to be shared by all—into fragmented and disorderly “private territories,” sharply contrasting with Japan’s well-managed streetscapes that serve as assets to tourism.

    To address this issue, citizens have submitted proposals through the government’s public policy participation platform, urging local authorities to take action and restore public space to the community.

    (more…)
  • 台灣的景觀亂象

    台灣許多街道常被一樓住戶以盆栽、三角錐等物品佔用人行道或路邊空間,形成私有化的現象。儘管這些行為影響市容與行人通行,地方政府卻長期放任、不積極取締,讓這類亂象成為習以為常的日常景觀。

    相較於日本整潔有序的街景,擅自擺放的盆栽、三角錐等雜物讓台灣街道顯得凌亂不堪。這些私占行為不僅妨礙通行,也嚴重拉低城市觀感。地方政府長期缺乏作為,使原本應該屬於全民的公共空間,變成零碎又雜亂的「私人地盤」,與日本街景作為觀光資產的形象形成強烈對比。

    為改善此現象,有民眾已在政府公共政策參與平台提出提案,期盼地方政府正視問題,還公共空間於市民:

    https://join.gov.tw/idea/detail/68dc2131-e3e7-4fcf-a66d-fded2712b519?fbclid=IwZXh0bgNhZW0CMTEAAR7oF7yQgSD4frW_PlbE6mvxqjAEVz1fX9zJlsb5bMaoyhLLqHvrpbBTPzP8jw_aem_0Z06c3SyKtMMsVmu7Uup8g

    (more…)
  • Trump 川普關稅衝擊報告 by 財經M平方

    Trump 川普關稅衝擊報告 by 財經M平方

    由財經M平方提供,針對 4/2 Trump 關稅政策的報告:cdn.macromicro.me/misc/202504/川普關稅衝擊完整解讀_財經M平方_20250407.pdf

    ​President Donald Trump’s recent implementation of comprehensive tariffs on all foreign imports has significantly impacted both the U.S. and global economies. These measures have led to increased production costs, consumer prices, and have raised concerns about potential recession risks.​

    (more…)
  • MIS Literacy

    As a competent MIS, one key point is to keep your equipment as consistent as possible with the most important person in the company: the boss. This makes it easier to solve problems and explain solutions clearly, whether in person or remotely.

    By using the same equipment as the boss, you’re more familiar with the system and can provide faster, more accurate support. It also ensures that you can troubleshoot effectively without any technical barriers.

    (Most recently caught norovirus, so take care of your health everyone.)

    身為一個稱職的MIS,身邊的資訊設備儘量跟老闆一致。除了可以更熟悉操作跟解問題外,也可以在不碰觸甚至遠端的方式說明清楚。(最近中了諾羅病毒…大家保重身體)

  • 川普團隊也在用 Signal?總編輯意外入群引發隱私風暴

    近日有消息指出,特朗普政府高層竟選擇用 Signal 這款加密通訊軟體來討論針對也門胡塞武裝的軍事打擊計劃,而在建立群聊時卻意外將《大西洋月刊》總編輯傑弗里·戈德堡加入群組…

    Apple App Store: Signal

    (more…)