Sign in


  1. 先統整 TEST 和 CI/CD 相關基礎知識。


後端 Back-end Roadmap-Testing&CI/CD


  1. 目的:觀察和理解 Middleware 中的:
    (1) app.use、(2) next()、(3) Router 順序,對 request 流向的影響。

Express-Using middleware

Express is a routing and middleware web framework that has minimal functionality of its own: An Express application is essentially a series of middleware function calls.

Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle. The next middleware function is commonly denoted by a variable named next.


以範例理解 Currying 觀念和屬於弱型別 JavaScript型別強制轉換特性。


Currying is an advanced technique of working with functions. It’s used not only in JavaScript, but in other languages as well.

Currying is a transformation of functions that translates a function from callable as f(a, b, c) into callable as f(a)(b)(c).

Currying doesn’t call a function. It just transforms it.

範例 1:

說明:(1) 資料傳遞方式、(2) 參數 x 和 y 值變化

  1. 命名 add5 = makeAdder(5),函式 makeAdder(x)的參數 x,固定代入
    5 後, 繼續執行inner func-return function(y)。
    但 inner func的return function(y) 只有參數 y,沒有 x,所以只會計算 x。

範例 2…


Alpha Camp 課程中,依據不同教師,包含約 2–3 種不同 Route 分流寫法。

我選擇對於自己較易理解的寫法,歸納統整成 organizational chart (組織圖),幫助提點記憶和快速查詢。

express-router 套件 (npm 官網)

express-router is a library for organizing routes of an express application.

express-router lets you write your express routes in a simpler way.
You just have to create a ‘routes’ folder inside your project and place your routes in an index.txt file.

規劃 Route 分流,主要參與對象(檔案)共 4 個:

  1. app.js

app.js 結構:


5. 重新上傳 Heroku:.env&FACEBOOK for Developers


佈署 Heroku,以整合第三方 API-Imgur 切換成 MySQL Database 為例,步驟和指令:

  1. 前置作業
    (1) 建立個人 Heroku 帳號
    (2) Heroku CLI:Download and install

2. PostgreSQL ( Heroku 預設 )

(1) 安裝套件:node-postgres

(2) 修改 config/config.json production 模式

(3) 建立 git commit

(4) Heroku CLI 初始化

(5) 佈署至 Heroku

(6) Heroku 啟動專案

(7) 建立 Heroku 新資料庫

(8) app.js 修改 Port

(9) 定義啟動腳本 Procfile

(10) 重新 commit,並上傳 Heroku

(11) 執行 Migration & Seeder

3. 整合 Imgur API

(1) 註冊 Imgur 帳號

(2) 安裝套件:imgur-node-api


Also on Strikingly:



  1. 立即函式 IIFE (Immediately Invoked Function Expression)


學習 this 觀念後,後續遇到應用情境,仍似懂非懂,因此歸納統整,儘量明確釐清:(1) this、(2) 前端 Views (MVC Framework)、(3) 物件導向的 Constructor (建構式函式),3者觀念和實務應用情境。

目前自己實務上,常用操作情境和 this 觀念:

  1. 前端 Views (MVC Framework):
    (1) 使用 this 的 Implicit Binding (隱式綁定),即 this 自動指向最近(父層)的 Object。
    (2) Controllers 將 Array Data 傳至 Views,Views 搭配 this 指向該 Array,幫助 render 頁面。

this 定義

  1. JavaScript 中的 this ,會在調用某個 function 時,「自動」添加到該 function 中。

Also on Strikingly:


新增 URL (取得 “網址” 內容):2-3. req.method (取得 HTTP Method)



The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on. In this documentation and by convention, the object is always referred to as req (and the HTTP response is res) but its actual name is determined by the parameters to the callback function in which you’re working.

根據常用 req 內容,依來源位置,歸納為 4 類(共5種):

  1. HTML Form (取得 “表單” 內容):req.body

Also on Strikingly:


  1. 主要以 3 種方式統整常用陣列相關函數:

(1) 歸納功能類別:目前共12種功能分類
(2) 區分相似函數:如 slice()、splice()
(3) 區分該函數對原陣列影響:標註 改變/不改變 原陣列

2. 之後擴充時,主要新增 3 種情況:

(1) 上述既有架構內,新增其他函數。
(2) 新功能類別:如第13種功能大分類。
(3) 新實務運用:如 [對稱合併 2 陣列] 等實務操作,方便之後快速檢索和組合運用。

一、Array-related Functions

  1. 去頭、去尾

Also on Strikingly:


  1. 以 MECE (Mutually Exclusive, Collectively Exhaustive)原則,統整歸納Database 相關知識。

Database 分類架構

Data Structure

Also on Strikingly:


雖已完成 JSON Web Token (JWT) 登入驗證機制,但一段時間後很容易忘記,因此統整出框架和重要觀念。

MDN-HTTP is stateless, but not sessionless

HTTP is stateless: there is no link between two requests being successively carried out on the same connection.
每個 request 獨立,Server 端和 Client 端不保持連線狀態,因此雙方狀態無即時更新。

This immediately has the prospect of being problematic for users attempting to interact with certain pages coherently, for example, using e-commerce shopping baskets.

But while the core of HTTP itself is stateless, HTTP cookies allow the use of stateful sessions.

Using header extensibility, HTTP Cookies are added to the workflow, allowing session creation on each HTTP request to share…

Ryan Lai

Equipped with web development, communication, and business analytical skills.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store