[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"academy-blogs-th-1-1-all-js2go-ep46-middleware-modular-architecture-go-nodejs-all--*":3,"academy-blog-translations-06v021j7mqri9t7":75},{"data":4,"page":74,"perPage":74,"totalItems":74,"totalPages":74},[5],{"alt":6,"collectionId":7,"collectionName":8,"content":9,"cover_image":10,"cover_image_path":11,"created":12,"created_by":13,"expand":14,"id":68,"keywords":69,"locale":44,"published_at":70,"scheduled_at":13,"school_blog":66,"short_description":71,"slug":72,"status":64,"title":6,"updated":73,"updated_by":13,"views":67},"JS2GO EP.46 การสร้าง Middleware และ Modular Architecture ใน Go และ Node.js","sclblg987654321","school_blog_translations","\u003Cp>เขียน API ให้รันได้ = ง่าย\u003C\u002Fp>\u003Cp>เขียน API ให้ดูแลง่าย ขยายง่าย และรอดใน Production = ต้องใช้สถาปัตยกรรมที่ดี\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>บทความนี้จะสรุปตั้งแต่พื้นฐาน → ระดับองค์กร (Enterprise)\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>สิ่งที่คุณจะได้เรียนรู้\u003C\u002Fp>\u003Cp>✔ การสร้าง Middleware (Auth, Logging, Rate Limit)\u003Cbr>✔ Service \u002F Repository Pattern\u003Cbr>✔ Modular Architecture แบบ Production-ready\u003Cbr>✔ ตัวอย่างโค้ด Express + Fiber ที่ถูกต้อง\u003Cbr>✔ Best Practices ที่ใช้ในบริษัทจริง\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>⭐ 1) Middleware คืออะไร?\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Middleware = ฟังก์ชันที่ถูกเรียกก่อน (หรือหลัง) Handler\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>มีไว้สำหรับงานประเภท:\u003C\u002Fp>\u003Cul>\u003Cli>ตรวจสอบ Authorization \u002F Token\u003C\u002Fli>\u003Cli>Logging request\u003C\u002Fli>\u003Cli>Rate Limiting\u003C\u002Fli>\u003Cli>Request Transform (เช่น normalize headers)\u003C\u002Fli>\u003Cli>Validation\u003C\u002Fli>\u003Cli>ตรวจสอบสิทธิ์ของผู้ใช้\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>Flow (เหมือนกันทั้ง Go และ Node.js)\u003C\u002Fh3>\u003Cpre>\u003Ccode class=\"language-plaintext\">Request → Middleware A → Middleware B → Handler → Response\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Handler ควร “บางที่สุด” เพราะงานหนักควรถูกดันไป Service Layer หรือ Middleware\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>⭐ 2) ตัวอย่าง Middleware ที่ถูกต้องและใช้งานได้จริง\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>🔹 Logging Middleware\u003C\u002Fh3>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch4>Go (Fiber)\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext language-go\">func Logging() fiber.Handler {\n    return func(c *fiber.Ctx) error {\n        start := time.Now()\n\n        err := c.Next()\n\n        fmt.Printf(\"[%s] %s - %d (%v)\\n\",\n            c.Method(),\n            c.Path(),\n            c.Response().StatusCode(),\n            time.Since(start),\n        )\n\n        return err\n    }\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Register\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-go\">app.Use(Logging())\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch4>Node.js (Express)\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext language-js\">function logger(req, res, next) {\n  const start = Date.now();\n  res.on(\"finish\", () =&gt; {\n    console.log(`[${req.method}] ${req.url} - ${res.statusCode} (${Date.now() - start}ms)`);\n  });\n  next();\n}\n\napp.use(logger);\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>🔹 Authentication Middleware\u003C\u002Fh3>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch4>Go (Fiber)\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext language-go\">func Auth() fiber.Handler {\n    return func(c *fiber.Ctx) error {\n        token := c.Get(\"Authorization\")\n        if token == \"\" {\n            return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{\n                \"error\": \"Missing Authorization header\",\n            })\n        }\n        return c.Next()\n    }\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch4>Node.js (Express)\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext language-js\">function auth(req, res, next) {\n  const token = req.headers.authorization;\n  if (!token) return res.status(401).json({ error: \"Unauthorized\" });\n  next();\n}\n\napp.use(auth);\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>🔹 Rate Limit (Basic Example สำหรับสาธิต ไม่เหมาะกับ Production)\u003C\u002Fh3>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch4>Go\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext language-go\">func RateLimit() fiber.Handler {\n    var mu sync.Mutex\n    var count = 0\n\n    return func(c *fiber.Ctx) error {\n        mu.Lock()\n        if count &gt;= 100 {\n            mu.Unlock()\n            return c.Status(429).SendString(\"Too Many Requests\")\n        }\n        count++\n        mu.Unlock()\n\n        return c.Next()\n    }\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch4>Node.js\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext language-js\">let count = 0;\n\nfunction rateLimit(req, res, next) {\n  if (count &gt;= 100) {\n    return res.status(429).send(\"Too Many Requests\");\n  }\n  count++;\n  next();\n}\n\napp.use(rateLimit);\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>➡ ใน Production ควรใช้ Redis + Token Bucket \u002F Sliding Window\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>⭐ 3) Modular Architecture คืออะไร?\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>โครงสร้างแบบ Modular = ทุกโมดูลดูแลตัวเอง (self-contained)\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>ช่วยให้ระบบ:\u003C\u002Fp>\u003Cul>\u003Cli>แก้ไขง่าย\u003C\u002Fli>\u003Cli>เพิ่มฟีเจอร์ได้โดยไม่แตะส่วนอื่น\u003C\u002Fli>\u003Cli>แยก test ได้ง่าย\u003C\u002Fli>\u003Cli>เหมาะกับระบบขนาดกลาง–ใหญ่\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>📌 โครงสร้างใน Go (Production-ready)\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">\u002Fcmd\u002Fserver\u002Fmain.go\n\u002Finternal\n   \u002Fuser\n      handler.go\n      service.go\n      repository.go\n      model.go\n   \u002Fproduct\n      handler.go\n      service.go\n      repository.go\n\u002Fpkg\n   \u002Fdatabase\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>📌 โครงสร้างใน Node.js (Express)\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">src\u002F\n ├─ modules\u002F\n │   ├─ user\u002F\n │   │   ├─ user.controller.js\n │   │   ├─ user.service.js\n │   │   ├─ user.repository.js\n │   │   ├─ user.model.js\n │   ├─ product\u002F\n ├─ middlewares\u002F\n ├─ routes\u002F\n ├─ database\u002F\n ├─ app.js\n ├─ server.js\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>⭐ 4) Service \u002F Repository Pattern คืออะไร?\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>แยกความรับผิดชอบตามลำดับชั้น:\u003C\u002Fp>\u003Cfigure class=\"table\">\u003Ctable>\u003Cthead>\u003Ctr>\u003Cth>Layer\u003C\u002Fth>\u003Cth>หน้าที่\u003C\u002Fth>\u003C\u002Ftr>\u003C\u002Fthead>\u003Ctbody>\u003Ctr>\u003Ctd>Handler \u002F Controller\u003C\u002Ftd>\u003Ctd>รับ Request → เรียก Service → ส่ง Response\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Service\u003C\u002Ftd>\u003Ctd>Logic ธุรกิจ เช่น Validation, Rule, Workflow\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>Repository\u003C\u002Ftd>\u003Ctd>คุยกับ Database เท่านั้น\u003C\u002Ftd>\u003C\u002Ftr>\u003C\u002Ftbody>\u003C\u002Ftable>\u003C\u002Ffigure>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>ตัวอย่างใน Go (Fiber)\u003C\u002Fh3>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch4>Handler\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext language-go\">func (h *UserHandler) GetUser(c *fiber.Ctx) error {\n    id := c.Params(\"id\")\n\n    user, err := h.Service.GetUser(c.Context(), id)\n    if err != nil {\n        return c.Status(404).JSON(fiber.Map{\"error\": \"User not found\"})\n    }\n\n    return c.JSON(user)\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch4>Service\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext language-go\">func (s *UserService) GetUser(ctx context.Context, id string) (*User, error) {\n    return s.Repo.FindByID(ctx, id)\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch4>Repository\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext language-go\">func (r *UserRepository) FindByID(ctx context.Context, id string) (*User, error) {\n    row := r.DB.QueryRow(ctx, \"SELECT id, name FROM users WHERE id=$1\", id)\n\n    var u User\n    if err := row.Scan(&amp;u.ID, &amp;u.Name); err != nil {\n        return nil, err\n    }\n\n    return &amp;u, nil\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>ตัวอย่าง Node.js (Express)\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>Controller\u003C\u002Fh3>\u003Cpre>\u003Ccode class=\"language-plaintext language-js\">export const getUser = async (req, res) =&gt; {\n  const user = await userService.getUser(req.params.id);\n  if (!user) return res.status(404).send(\"User not found\");\n  res.json(user);\n};\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>Service\u003C\u002Fh3>\u003Cpre>\u003Ccode class=\"language-plaintext language-js\">export const userService = {\n  getUser: async (id) =&gt; userRepository.findById(id),\n};\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>Repository\u003C\u002Fh3>\u003Cpre>\u003Ccode class=\"language-plaintext language-js\">export const userRepository = {\n  findById: async (id) =&gt; {\n    const result = await pool.query(\n      \"SELECT id, name FROM users WHERE id=$1\",\n      [id]\n    );\n    return result.rows[0];\n  },\n};\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>⭐ 5) Project Structure ที่ใช้จริงใน Production\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>ทั้ง Go และ Node.js ใช้ pattern แบบแยก module + service + repository เพื่อให้รองรับทีมใหญ่และระบบที่เติบโตต่อเนื่อง\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>⭐ 6) Best Practices สำหรับองค์กร\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>✔ Controller ต้อง “บาง” ไม่มี business logic\u003Cbr>✔ Service ไม่แตะ database\u003Cbr>✔ Repository ไม่รู้กฎของธุรกิจ\u003Cbr>✔ อย่าทำ middleware ทำงานหนัก (เพิ่ม latency)\u003Cbr>✔ ใช้ Dependency Injection (จะสอนใน EP.47)\u003Cbr>✔ ตั้งชื่อไฟล์ตามหน้าที่ เช่น \u003Ccode inline=\"\">user.service.js\u003C\u002Fcode> ไม่ใช่ \u003Ccode inline=\"\">service.js\u003C\u002Fcode>\u003Cbr>✔ Mock service\u002Frepository เพื่อเขียน unit test\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Chr>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>📌 สรุป\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>เมื่อคุณใช้:\u003C\u002Fp>\u003Cul>\u003Cli>Middleware ที่ออกแบบดี\u003C\u002Fli>\u003Cli>Modular Architecture\u003C\u002Fli>\u003Cli>Service\u002FRepository Pattern\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>ระบบของคุณจะ:\u003C\u002Fp>\u003Cp>🚀 ขยายง่าย\u003Cbr>🧱 เสถียร\u003Cbr>🔍 เทสง่าย\u003Cbr>💼 พร้อมใช้งาน Production จริง\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>นี่คือเหตุผลว่าทำไมองค์กรใหญ่และซอฟต์แวร์เฮาส์มืออาชีพถึงใช้สถาปัตยกรรมแนวนี้\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🔵 ตอนต่อไป: EP.47 Dependency Injection ใน Go และ Node.js\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>คุณจะได้เรียนรู้ว่า:\u003C\u002Fp>\u003Cul>\u003Cli>DI ทำให้ระบบ testable ขนาดไหน\u003C\u002Fli>\u003Cli>Constructor-based Injection ใน Go\u003C\u002Fli>\u003Cli>DI Container ใน Node.js\u003C\u002Fli>\u003Cli>Mock Service\u002FRepository อย่างไรให้เทสง่าย\u003C\u002Fli>\u003Cli>ออกแบบ Dependency Graph ของระบบอย่างถูกต้อง\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cdiv class=\"raw-html-embed\">\u003Cdiv style=\"margin:0 0 6px 0; font-weight:700;\">อ่านบทความ Series อื่นๆ:\u003C\u002Fdiv>\n\u003Cul style=\"list-style:none; padding:0; margin:0; line-height:1.4;\">\n  \u003Cli style=\"margin:0;\">\u003Ca href=\"\u002Fblogs\u002Fcategories\u002FGolang\" title=\"Golang The Series\">Golang The Series\u003C\u002Fa>\u003C\u002Fli>\n  \u003Cli style=\"margin:0;\">\u003Ca href=\"\u002Fblogs\u002Fcategories\u002FJS2GO\" title=\"JS2GO\">JS2GO\u003C\u002Fa>\u003C\u002Fli>\n  \u003Cli style=\"margin:0;\">\u003Ca href=\"\u002Fblogs\u002Fcategories\u002FTailwind%20CSS\" title=\"10 Ep ที่จะให้คุณเป็นมือโปร Tailwind CSS ในชั่วข้ามคืน\">10 Ep ที่จะให้คุณเป็นมือโปร Tailwind CSS ในชั่วข้ามคืน\u003C\u002Fa>\u003C\u002Fli>\n\u003C\u002Ful>\u003C\u002Fdiv>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cdiv class=\"raw-html-embed\">\n  \u003Cp style=\"margin:0 0 6px 0;\">\u003Cstrong>Follow Us:\u003C\u002Fstrong>\u003C\u002Fp>\n  \u003Cul style=\"list-style:none; padding:0; margin:0; line-height: 0.4;\">\n    \u003Cli style=\"display:flex; align-items:center; gap:6px; margin:0;\">\n      \n      \u003Csvg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"#1877F2\" aria-hidden=\"true\">\n        \u003Cpath d=\"M22 12.07C22 6.48 17.52 2 11.93 2S2 6.48 2 12.07c0 5 3.66 9.14 8.44 9.93v-7.02H7.9v-2.91h2.54V9.41c0-2.5 1.49-3.88 3.77-3.88 1.09 0 2.24.2 2.24.2v2.46h-1.26c-1.24 0-1.63.77-1.63 1.56v1.87h2.78l-.44 2.91h-2.34V22c4.78-.79 8.44-4.93 8.44-9.93Z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Ca href=\"https:\u002F\u002Fwww.facebook.com\u002Fsuperdev.academy.th\" target=\"_blank\" rel=\"nofollow noopener\" title=\"Follow Superdev Academy on Facebook\">Facebook: Superdev Academy\u003C\u002Fa>\n    \u003C\u002Fli>\n\n    \u003Cli style=\"display:flex; align-items:center; gap:6px; margin:0;\">\n      \n      \u003Csvg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"#FF0000\" aria-hidden=\"true\">\n        \u003Cpath d=\"M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.5 12 3.5 12 3.5s-7.5 0-9.4.6A3 3 0 0 0 .5 6.2 31.5 31.5 0 0 0 0 12a31.5 31.5 0 0 0 .5 5.8 3 3 0 0 0 2.1 2.1c1.9.6 9.4.6 9.4.6s7.5 0 9.4-.6a3 3 0 0 0 2.1-2.1A31.5 31.5 0 0 0 24 12a31.5 31.5 0 0 0-.5-5.8ZM9.75 15.02V8.98L15.5 12l-5.75 3.02Z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Ca href=\"https:\u002F\u002Fwww.youtube.com\u002F@SuperdevAcademy\" target=\"_blank\" rel=\"nofollow noopener\" title=\"Watch on YouTube\">YouTube: Superdev Academy\u003C\u002Fa>\n    \u003C\u002Fli>\n\n    \u003Cli style=\"display:flex; align-items:center; gap:6px; margin:0;\">\n      \n      \u003Csvg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"#E4405F\" aria-hidden=\"true\">\n        \u003Cpath d=\"M7 2h10a5 5 0 0 1 5 5v10a5 5 0 0 1-5 5H7a5 5 0 0 1-5-5V7a5 5 0 0 1 5-5Zm10 2H7a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3-3V7a3 3 0 0 0-3-3Zm-5 3.5A5.5 5.5 0 1 1 6.5 13 5.5 5.5 0 0 1 12 7.5Zm0 2A3.5 3.5 0 1 0 15.5 13 3.5 3.5 0 0 0 12 9.5Zm5.75-2.75a1.25 1.25 0 1 1-1.25 1.25 1.25 1.25 0 0 1 1.25-1.25Z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Ca href=\"https:\u002F\u002Fwww.instagram.com\u002Fsuperdevacademy\u002F?hl=en target=\" _blank\"=\"\" rel=\"nofollow noopener\" title=\"See behind-the-scenes on Instagram\">Instagram: Superdev Academy\u003C\u002Fa>\n    \u003C\u002Fli>\n\n    \u003Cli style=\"display:flex; align-items:center; gap:6px; margin:0;\">\n      \n      \u003Csvg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"#000000\" aria-hidden=\"true\">\n        \u003Cpath d=\"M21 8.12a6.86 6.86 0 0 1-4.8-2V16a6 6 0 1 1-6-6 5.9 5.9 0 0 1 1.63.23V8.05a9.08 9.08 0 0 1-1.63-.15V4.5a6.86 6.86 0 0 0 4.8 2.05V6.5a6.86 6.86 0 0 0 4.8 1.62ZM9.2 12.5A3.5 3.5 0 1 0 12.7 16V9.94a6 6 0 0 1-1.63-.27v3.95a3.5 3.5 0 0 1-1.87 3.17 3.5 3.5 0 0 1-4.78-3.23 3.5 3.5 0 0 1 4.78-3.06Z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Ca href=\"https:\u002F\u002Fwww.tiktok.com\u002F@superdevacademy\" target=\"_blank\" rel=\"nofollow noopener\" title=\"Watch short tips on TikTok\">TikTok: @superdevacademy\u003C\u002Fa>\n    \u003C\u002Fli>\n\n    \u003Cli style=\"display:flex; align-items:center; gap:6px; margin:0;\">\n      \n      \u003Csvg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"#111827\" aria-hidden=\"true\">\n        \u003Cpath d=\"M12 2a10 10 0 1 0 10 10A10.01 10.01 0 0 0 12 2Zm6.93 6h-3.26a15.6 15.6 0 0 0-1.39-3.62A8.03 8.03 0 0 1 18.93 8ZM12 4c.73.93 1.7 2.74 2.2 4H9.8C10.3 6.74 11.27 4.93 12 4ZM8.72 4.38A15.6 15.6 0 0 0 7.32 8H4.07a8.03 8.03 0 0 1 4.65-3.62ZM4.07 16h3.25a15.6 15.6 0 0 0 1.4 3.62A8.03 8.03 0 0 1 4.07 16ZM12 20c-.73-.93-1.7-2.74-2.2-4h4.4C13.7 17.26 12.73 19.07 12 20Zm3.28-.38A15.6 15.6 0 0 0 16.68 16h3.25a8.03 8.03 0 0 1-4.65 3.62ZM20 14h-3.54a13.8 13.8 0 0 1-.26-4H20a7.98 7.98 0 0 1 0 4Zm-12.2 0H4a7.98 7.98 0 0 1 0-4h3.54a13.8 13.8 0 0 1-.26 4Zm2 .5h4.4a17.8 17.8 0 0 1-.72-4.5c0-1.58.25-3.1.72-4.5H9.8a17.8 17.8 0 0 1 .72 4.5c0 1.58-.25 3.1-.72 4.5Z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Ca href=\"https:\u002F\u002Fwww.superdevacademy.com\u002F\" target=\"_blank\" rel=\"noopener\" title=\"Visit the official website of Superdev Academy\">Official Website: Superdev Academy.com\u003C\u002Fa>\n    \u003C\u002Fli>\n  \u003C\u002Ful>\n\u003C\u002Fdiv>\u003Cp>&nbsp;\u003C\u002Fp>","cover_image_js2_go_ep_46_building_middleware_and_modular_architecture_in_go_and_node_exrof0jwyi.js.webp","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclblg987654321\u002Fddfdxscguz1ldsl\u002Fcover_image_js2_go_ep_46_building_middleware_and_modular_architecture_in_go_and_node_exrof0jwyi.js.webp","2026-03-04 08:45:03.591Z","",{"keywords":15,"locale":38,"school_blog":48},[16,23,28,33],{"collectionId":17,"collectionName":18,"created":19,"created_by":13,"id":20,"name":21,"updated":22,"updated_by":13},"sclkey987654321","school_keywords","2026-03-04 08:24:40.405Z","05u3tysava2z6ga","Node.js","2026-04-10 16:07:29.504Z",{"collectionId":17,"collectionName":18,"created":24,"created_by":13,"id":25,"name":26,"updated":27,"updated_by":13},"2026-03-04 08:20:11.547Z","ey3puyme01a9bsw","Go","2026-04-10 16:07:25.893Z",{"collectionId":17,"collectionName":18,"created":29,"created_by":13,"id":30,"name":31,"updated":32,"updated_by":13},"2026-03-04 08:45:02.900Z","12i9ika4aocvtm5","Modular Architecture","2026-04-10 16:12:53.598Z",{"collectionId":17,"collectionName":18,"created":34,"created_by":13,"id":35,"name":36,"updated":37,"updated_by":13},"2026-03-04 08:34:25.436Z","bctyeonwhcrzvq3","Middleware","2026-04-10 16:08:14.305Z",{"code":39,"collectionId":40,"collectionName":41,"created":42,"flag":43,"id":44,"is_default":45,"label":46,"updated":47},"th","pbc_1989393366","locales","2026-01-22 10:59:55.832Z","twemoji:flag-thailand","s8wri3bt4vgg2ji",true,"Thai","2026-04-10 15:42:46.614Z",{"category":49,"collectionId":50,"collectionName":51,"expand":52,"id":66,"views":67},"hsa1afr8fcnd6qb","pbc_2105096300","school_blogs",{"category":53},{"blogIds":54,"collectionId":55,"collectionName":56,"created":57,"created_by":13,"id":49,"image":58,"image_alt":13,"image_path":59,"label":60,"name":61,"priority":62,"publish_at":63,"scheduled_at":13,"status":64,"updated":65,"updated_by":13},[],"sclcatblg987654321","school_category_blogs","2026-03-04 08:24:37.986Z","js2_go_2_11zon_y6paxmuz32.webp","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclcatblg987654321\u002Fhsa1afr8fcnd6qb\u002Fjs2_go_2_11zon_y6paxmuz32.webp",{"en":61,"th":61},"JS2GO",10,"2025-08-11 03:41:08.820Z","published","2026-04-25 02:32:14.339Z","06v021j7mqri9t7",246,"ddfdxscguz1ldsl",[20,25,30,35],"2025-12-17 02:25:26.894Z","เรียนรู้การสร้าง Middleware (Auth, Logging, Rate Limit) และออกแบบ Modular Architecture แบบองค์กรใน Go และ Node.js พร้อมตัวอย่างโค้ด Fiber + Express และ Best Practices ที่ใช้จริงในระบบ Production","js2go-ep46-middleware-modular-architecture-go-nodejs","2026-04-25 02:47:48.764Z",1,{"th":72}]