it_devops

TypeScript tRPC Cloud Native Design — คู่มือฉบับสมบูรณ์ 2026

TypeScript tRPC Cloud Native Design — คู่มือฉบับสมบูรณ์ 2026

TypeScript tRPC Cloud Native Design คืออะไร

TypeScript tRPC Cloud Native Design เป็นรูปแบบการออกแบบระบบที่รวม TypeScript, tRPC (TypeScript Remote Procedure Call) และหลักการ Cloud Native

เข้าด้วยกันเพื่อสร้างแอปพลิเคชันเว็บที่มีประสิทธิภาพสูงและปลอดภัย ในมุมมองของนักพัฒนาที่มีประสบการณ์กว่า 13 ปี ผมพบว่ารูปแบบนี้กำลังกลายเป็นมาตรฐานใหม่ในการสร้างระบบสมัยใหม่ โดยเฉพาะเมื่อต้องจัดการกับข้อมูลที่เปลี่ยนแปลงตลอดเวลา เช่น ข้อมูลราคาทองคำและอัตราแลกเปลี่ยน

tRPC เป็นไลบรารีที่ช่วยให้การสื่อสารระหว่าง client และ server มีความปลอดภัยด้าน type โดยอัตโนมัติ เมื่อรวมกับ TypeScript แล้ว เราจะได้ระบบที่ตรวจสอบความถูกต้องของข้อมูลตั้งแต่ขั้นตอนการพัฒนา ไม่ต้องรอให้ถึงขั้นตอนทดสอบหรือใช้งานจริง

หลักการ Cloud Native ที่นำมาใช้ประกอบด้วย Containerization, Microservices, Service Discovery, และ Automated Scaling ซึ่งทำให้ระบบสามารถขยายขนาดได้ตามความต้องการโดยไม่ต้องหยุดทำงาน

เทคโนโลยี/หลักการรายละเอียดประโยชน์
TypeScriptภาษายอดนิยมสำหรับ web developmentตรวจสอบ type ได้ตั้งแต่ compile time
tRPCTypeScript Remote Procedure Callลดเวลาพัฒนา 30-40% ไม่ต้องเขียน API doc ซ้ำ
ContainerizationDocker, Kubernetesขยายระบบได้ตามความต้องการ
Microservicesแยกบริการเป็นโมดูลอิสระบำรุงรักษาง่าย พัฒนาพร้อมกันได้
Service Discoveryค้นหาบริการอัตโนมัติระบบมีความยืดหยุ่นสูง
Automated Scalingขยาย/ลดทรัพยากรอัตโนมัติประหยัดต้นทุน รองรับ load สูง

ในปี 2026 ตลาด Cloud Computing มีมูลค่ากว่า 832 พันล้านดอลลาร์สหรัฐ

การเรียนรู้รูปแบบการออกแบบระบบนี้จึงมีความสำคัญอย่างยิ่งสำหรับนักพัฒนาที่ต้องการพัฒนาทักษะให้ทันกับมาตรฐานอุตสาหกรรม

ในปี 2026 ตลาด Cloud Computing มีมูลค่ากว่า 832 พันล้านดอลลาร์สหรัฐ การเรียนรู้รูปแบบการออกแบบระบบนี้จึงมีความสำคัญอย่างยิ่งสำหรับนักพัฒนาที่ต้องการพัฒนาทักษะให้ทันกับมาตรฐานอุตสาหกรรม

จากประสบการณ์ของผม การสร้างระบบด้วย TypeScript tRPC Cloud Native Design ช่วยลดเวลาในการพัฒนาได้ประมาณ 30-40% เมื่อเทียบกับรูปแบบเดิม เนื่องจากไม่ต้องเขียน API documentation ซ้ำซ้อนและไม่ต้องกังวลเรื่อง type mismatch ระหว่าง client และ server

องค์กรชั้นนำทั่วโลกอย่าง Google, Netflix, Amazon และ Spotify ต่างก็ใช้เทคโนโลยีที่เกี่ยวข้องกับรูปแบบนี้ในการสร้างระบบที่มี scalability สูง reliability ดี และ maintain ง่าย

สำหรับนักพัฒนาไทย การมีความรู้ในด้านนี้จะเพิ่มโอกาสในการรับงาน freelance ระดับสูงหรือตำแหน่งงานในองค์กรข้ามชาติที่เข้ามาลงทุนในประเทศไทย

tRPC เป็น RPC framework สำหรับ TypeScript ที่เน้นความปลอดภัยของ type end-to-end โดยไม่ต้องใช้ OpenAPI spec หรือ manual schema generation ซึ่งต่างจาก gRPC ที่ต้องเขียน .proto file และ compile ทุกครั้ง tRPC ใช้ TypeScript type system โดยตรง ทำให้เมื่อคุณเปลี่ยนแปลง type ที่ server client จะรู้ทันทีผ่าน type inference

ในบริบท cloud native architecture tRPC เหมาะสมเพราะมัน lightweight ไม่มี overhead ของ protobuf encoding และทำงานได้ดีกับ HTTP/2 และ WebSocket protocols ที่ใช้กันทั่วไปใน cloud environment การออกแบบแบบ contract-first ของ tRPC ยังช่วยให้ทีม frontend และ backend ทำงานพร้อมกันได้โดยมี shared type definitions เป็น single source of truth

สิ่งที่ทำให้ tRPC แตกต่างจาก REST API คือการที่มันไม่ต้องการ manual documentation หรือ code generation tools ทำให้ developer experience เร็วและ smoother โดยเฉพาะใน microservices environment ที่ต้องการ rapid iteration และ tight coupling ระหว่าง services

tRPC คือ TypeScript Remote Procedure Call ซึ่งเป็นเครื่องมือที่ช่วยให้คุณสามารถเรียกฟังก์ชันจากเซิร์ฟเวอร์ได้เหมือนเรียกฟังก์ชันภายในตัว โดยไม่ต้องผ่าน API endpoint แบบ REST หรือ GraphQL อีกต่อไป สำหรับนักพัฒนาที่ทำงานกับ TypeScript ทั้งฝั่ง client และ server แล้ว tRPC จะลดความซับซ้อนลงได้อย่างมาก เพราะไม่ต้องเขียน interface file แยก ไม่ต้องจัดการ type definition ซ้ำซ้อน และที่สำคัญคือมี type safety ตั้งแต่เริ่มต้นจนถึงปลายทาง

ในบริบทของ cloud native design แล้ว tRPC เข้ากันได้ดีมากกับ microservices architecture เพราะช่วยให้บริการต่าง ๆ สามารถสื่อสารกันได้อย่างปลอดภัยทาง type โดยไม่ต้องพึ่งพา documentation ที่อาจล้าสมัยหรือ schema file ที่ต้อง sync กันตลอดเวลา ระบบสามารถ scale ออกไปได้อย่างยืดหยุ่น และเมื่อมีการเปลี่ยนแปลง API ก็จะสามารถรู้ได้ทันทีจาก TypeScript compiler ไม่ใช่รอจน runtime error เกิดขึ้น

สำหรับนักเทรดและคนที่ทำงานกับข้อมูลแบบ real-time เช่น ระบบ signal trading หรือ dashboard แสดงราคาแล้ว tRPC จะช่วยลด latency และเพิ่มความแม่นยำของข้อมูล เพราะมีการ serialize/deserialize ที่เบาและตรงไปตรงมา ไม่ต้องผ่าน JSON schema validation layer ที่ซับซ้อน

tRPC เป็น library ที่ช่วยให้เราสร้าง API ที่มีความปลอดภัยแบบ type-safe ระหว่าง client และ server โดยใช้ TypeScript เป็นตัวกลาง เราไม่ต้องเขียน schema หรือ OpenAPI spec เหมือน GraphQL หรือ REST เพราะ tRPC จะดึง type จากโค้ด TypeScript โดยตรง ทำให้เมื่อเราเปลี่ยน interface บน server แล้ว compile error จะปรากฏทันทีบน client

ในมุมมอง cloud native design การใช้งาน tRPC ช่วยให้สถาปัตยกรรมของเราสามารถ scale ได้ง่าย เพราะ API endpoint แต่ละตัวเป็น stateless function ที่ deploy บน container หรือ serverless function ได้ทันที เมื่อรวมกับ Docker, Kubernetes และ service mesh เช่น Istio เราจะได้ระบบที่ resilient, observable และ easy to maintain

สิ่งที่ทำให้ tRPC แตกต่างจาก RPC framework อื่นคือ "end-to-end type safety" ซึ่งหมายความว่า type ของ request, response และ error ถูกตรวจสอบตั้งแต่การเขียนโค้ดจนไปถึง runtime ทำให้ bug ที่เกี่ยวกับ type mismatch ลดลงอย่างมากใน production environment

การติดตั้งและตั้งค่าพื้นฐาน

เริ่มต้นด้วยการติดตั้ง Node.js และ npm บนระบบปฏิบัติการของคุณ สำหรับ Ubuntu/Debian ใช้คำสั่ง:

sudo apt update && sudo apt upgrade -y sudo apt install -y curl wget gnupg2 curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt install -y nodejs

สำหรับ CentOS/Rocky Linux/AlmaLinux ใช้คำสั่ง:

sudo dnf update -y sudo dnf install -y curl wget git jq curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash - sudo dnf install -y nodejs

สร้างโปรเจกต์ใหม่ด้วย TypeScript:

npx create-t3-app@latest my-trpc-app cd my-trpc-app npm install

ตั้งค่า environment variables ในไฟล์ `.env`:

DATABASE_URL=postgresql://user:password@localhost:5432/mydb REDIS_URL=redis://localhost:6379 JWT_SECRET=your-secret-key PORT=9090

การติดตั้ง tRPC เริ่มต้นด้วยการ npm install @trpc/server @trpc/client @trpc/react-query สำหรับ React apps และ @trpc/next สำหรับ Next.js integration จากนั้นสร้าง API router ที่ server side โดยกำหนด endpoints และ input types

import { initTRPC } from '@trpc/server';

const t = initTRPC.create();

export const appRouter = t.router({

getUser: t.procedure

.input((val) => typeof val === 'number')

.query(({ input }) => {

return { id: input, name: 'John Doe' };

}),

});

export type AppRouter = typeof appRouter;

ที่ client side สร้าง tRPC client ที่เชื่อมต่อกับ server endpoint และใช้ hooks สำหรับ data fetching

import { createTRPCReact } from '@trpc/react-query';

import { httpBatchLink } from '@trpc/client';

export const trpc = createTRPCReact();

// In your React component

const { data, isLoading } = trpc.getUser.useQuery(1);

การตั้งค่าพื้นฐานนี้ให้ type safety ตั้งแต่เริ่มต้น โดย TypeScript จะตรวจสอบ types ระหว่าง server และ client อัตโนมัติ

เริ่มต้นด้วยการติดตั้ง dependencies ที่จำเป็น ทั้งฝั่ง client และ server สำหรับฝั่ง server เราจะใช้ @trpc/server, @trpc/client และ @trpc/react-query สำหรับ React applications ส่วนฝั่ง infrastructure บน cloud จะใช้ Docker เพื่อ containerize application และ Kubernetes สำหรับ orchestration

การตั้งค่าเริ่มต้นค่อนข้างเรียบง่าย เพียงแค่สร้าง router หลักที่รวม endpoint ต่าง ๆ เข้าด้วยกัน กำหนด input types และ output types ให้ชัดเจน แล้ว expose router ผ่าน HTTP handler สำหรับ Next.js application สามารถใช้ tRPC adapter ได้โดยตรง ซึ่งทำให้ integrate กับ existing codebase ได้ง่ายมาก

สำหรับ cloud deployment การตั้งค่า environment variables และ connection strings ควรใช้ secrets management ของ cloud provider เช่น AWS Secrets Manager หรือ Google Secret Manager แทนที่จะ hardcode ใน codebase ซึ่งช่วยเพิ่ม security และทำให้สามารถ rotate credentials ได้สะดวก

เริ่มต้นด้วยการติดตั้ง dependency หลักสามตัวคือ @trpc/server สำหรับ backend, @trpc/client สำหรับ frontend และ @trpc/next ถ้าเราใช้ Next.js ในการพัฒนา web application การตั้งค่าเริ่มต้นค่อนข้างตรงไปตรงมา เราสร้าง router object บน server กำหนด procedure แต่ละตัวด้วย input type และ output type

import { initTRPC } from '@trpc/server';

import { z } from 'zod';

const t = initTRPC.create();

export const appRouter = t.router({

getUser: t.procedure

.input(z.object({ id: z.string() }))

.query(async ({ input }) => {

return { id: input.id, name: 'User' };

}),

});

export type AppRouter = typeof appRouter;

บน client side เรา import type ของ router มาใช้สร้าง TRPC client ที่มีความสามารถในการ auto-complete และ type checking โดยอัตโนมัติ การตั้งค่านี้ใช้เวลาไม่ถึง 10 นาที แต่ให้ประโยชน์ด้าน type safety ที่คุ้มค่ามากสำหรับทีมพัฒนาขนาดกลางถึงใหญ่

สถาปัตยกรรม Production ที่แนะนำ

สำหรับระบบ production ที่ต้องการความเสถียรสูง แนะนำให้ใช้สถาปัตยกรรมต่อไปนี้:

Application Layer: ใช้ Docker Compose หรือ Kubernetes เพื่อจัดการ container หลายตัวพร้อมกัน ตั้งค่า replicas อย่างน้อย 5 ตัวเพื่อรองรับ load สูง

Database Layer: ใช้ PostgreSQL ในรูปแบบ Primary-Replica พร้อม Auto-failover โดยใช้ Patroni หรือ PgBouncer เพื่อให้ระบบสามารถกู้คืนได้ภายใน 30 วินาที

Cache Layer: ใช้ Redis ในรูปแบบ Sentinel หรือ Cluster เพื่อรองรับการอ่านข้อมูลบ่อยๆ และลดภาระของ database

Load Balancer: ใช้ Nginx หรือ HAProxy เพื่อกระจาย traffic ไปยัง application instances ต่างๆ

Monitoring: ใช้ Prometheus สำหรับเก็บ metrics และ Grafana สำหรับ visualization พร้อมตั้งค่า alerting ผ่าน Alertmanager

Security: ใช้ Let's Encrypt สำหรับ SSL/TLS certificates และตั้งค่า firewall ด้วย UFW หรือ iptables

สำหรับ production deployment แนะนำให้ใช้ architectural pattern ที่เรียกว่า "API Gateway + Microservices" โดย API Gateway ทำหน้าที่เป็น single entry point สำหรับ client requests และ route requests ไปยัง microservices ที่เหมาะสม

Client → API Gateway (Kong/Envoy) → tRPC Router → Microservices

↓

Database

แต่ละ microservice ควรมี tRPC router ของตัวเอง และ expose endpoints ผ่าน API Gateway การใช้ Docker containers และ Kubernetes orchestration จะช่วยให้ scaling และ management ง่ายขึ้น

สำหรับการ monitoring แนะนำให้ใช้ OpenTelemetry instrumentation กับ tRPC เพื่อ track request latency, error rates และ throughput การทำ logging แบบ structured ด้วย JSON format จะช่วยให้ debugging ใน production environment ทำได้ง่ายขึ้น

สถาปัตยกรรม production ที่แนะนำสำหรับ tRPC application บน cloud คือการใช้ containerized services ที่ deploy บน Kubernetes cluster แต่ละ service ควรมี responsibility เดียวกันชัดเจน เช่น api-service สำหรับ tRPC endpoints, worker-service สำหรับ background jobs, และ data-service สำหรับ database operations

การสื่อสารระหว่าง services ควรผ่าน tRPC เพื่อรักษา type safety ทั่วทั้งระบบ แต่สำหรับ external APIs ที่ไม่สามารถใช้ tRPC ได้ ควรสร้าง adapter layer ที่แปลงระหว่าง tRPC types และ external API formats การออกแบบนี้ช่วยให้ระบบสามารถ evolve ไปตามเวลาได้โดยที่ client ไม่ต้องเปลี่ยนแปลง

สำหรับ scalability ควรใช้ horizontal scaling สำหรับ stateless services เช่น tRPC API servers และใช้ auto-scaling policies ที่ปรับตาม metrics เช่น CPU utilization, request latency หรือ queue length การทำ health checks และ readiness probes จะช่วยให้ Kubernetes สามารถจัดการ traffic routing ได้อย่างมีประสิทธิภาพ

สำหรับการใช้งาน tRPC ใน production environment ที่รองรับ cloud native design เราแนะนำให้ใช้ architecture แบบ microservices โดยมี API gateway อยู่หน้าสุด ทำหน้าที่ route request ไปยัง service ที่เหมาะสม แต่ละ service จะมี tRPC router ของตัวเองและ expose endpoint ผ่าน HTTP หรือ WebSocket

Layer แรกคือ Presentation Layer ที่ประกอบด้วย web application และ mobile app ที่ใช้ tRPC client ติดต่อ API Layer ซึ่งประกอบด้วย API gateway และ load balancer Layer ถัดมาคือ Service Layer ที่มี business logic แยกเป็น microservices หลายตัว แต่ละตัวมี tRPC router และ database ของตัวเอง

[Client Apps] → [API Gateway] → [Service A] → [DB A]

→ [Service B] → [DB B]

→ [Service C] → [DB C]

การออกแบบแบบนี้ช่วยให้แต่ละ service สามารถ deploy, scale และ maintain ได้อย่างอิสระ นอกจากนี้เรายังควรเพิ่ม observability tools เช่น OpenTelemetry, Prometheus และ Grafana เพื่อ monitor performance และ debug issues ใน production environment ได้อย่างมีประสิทธิภาพ

ตัวอย่างโค้ดและการใช้งานจริง

ตัวอย่างการสร้าง tRPC router ใน TypeScript:

import { initTRPC } from "@trpc/server"; import { z } from "zod";

const t = initTRPC.create();

export const goldPriceRouter = t.router({ getCurrentPrice: t.procedure .query(async () => { // Fetch from gold-api.com const response = await fetch("https://api.gold-api.com/price"); const data = await response.json(); return { price: data.price, currency: data.currency, updated: data.updated }; }),

convertPrice: t.procedure .input(z.object({ price: z.number(), from: z.string(), to: z.string() })) .query(async ({ input }) => { // Convert using frankfurter API const response = await fetch( `https://api.frankfurter.app/latest?from=${input.from}&to=${input.to}` ); const data = await response.json(); const rate = data.rates[input.to]; return { originalPrice: input.price, convertedPrice: input.price * rate, rate: rate }; }) });

ตัวอย่างการใช้งานจาก client:

import { createTRPCReact } from "@trpc/react-query"; import type { AppRouter } from "../server/router";

const trpc = createTRPCReact();

function GoldPriceWidget() { const { data, isLoading } = trpc.goldPrice.getCurrentPrice.useQuery();

if (isLoading) return

Loading...
;

return (

Gold Price

${data.price} {data.currency}

Updated: {new Date(data.updated).toLocaleString()}

); }

ตัวอย่างการใช้งาน tRPC ใน real-world scenario คือการสร้าง e-commerce API ที่รองรับ user authentication, product listing และ order management

// auth router

const authRouter = t.router({

login: t.procedure

.input(z.object({ email: z.string(), password: z.string() }))

.mutation(async ({ input }) => {

const user = await userService.findUserByEmail(input.email);

if (!user || !bcrypt.compareSync(input.password, user.password)) {

throw new TRPCError({ code: 'UNAUTHORIZED' });

}

return { token: jwt.sign({ userId: user.id }, SECRET) };

}),

});

// product router

const productRouter = t.router({

list: t.procedure

.input(z.object({ category: z.string().optional() }))

.query(async ({ input }) => {

return productService.findProducts(input);

}),

getById: t.procedure

.input(z.number())

.query(async ({ input }) => {

return productService.findProductById(input);

}),

});

// main router

export const appRouter = t.router({

auth: authRouter,

products: productRouter,

});

ที่ client side สามารถเรียกใช้ endpoints เหล่านี้ด้วย type safety

const { data: user } = trpc.auth.login.useMutation();

const { data: products } = trpc.products.list.useQuery({ category: 'electronics' });

ตัวอย่างการใช้งาน tRPC ใน production application เริ่มต้นด้วยการสร้าง router ที่รวม procedure ต่าง ๆ:

import { initTRPC } from '@trpc/server';

import { z } from 'zod';

const t = initTRPC.create();

export const router = t.router({

getSignal: t.procedure

.input(z.object({ symbol: z.string() }))

.query(async ({ input }) => {

// Fetch trading signal

return await signalService.get(input.symbol);

}),

executeTrade: t.procedure

.input(z.object({

symbol: z.string(),

quantity: z.number(),

type: z.enum(['buy', 'sell'])

}))

.mutation(async ({ input }) => {

return await tradeService.execute(input);

})

});

ฝั่ง client สามารถเรียกใช้ procedure เหล่านี้ได้แบบ type-safe:

import { trpc } from './trpc';

const signal = await trpc.getSignal.query({ symbol: 'EURUSD' });

const trade = await trpc.executeTrade.mutate({

symbol: 'EURUSD',

quantity: 100000,

type: 'buy'

});

การ integrate กับ cloud infrastructure ทำได้ผ่าน Dockerfile และ Kubernetes manifests ที่กำหนด resource limits, health checks และ scaling policies อย่างชัดเจน

คำถามที่พบบ่อย

TypeScript tRPC Cloud Native Design เหมาะกับมือใหม่ไหม

เหมาะครับถ้ามีพื้นฐาน TypeScript และ React เบื้องต้น แนะนำให้เริ่มจากการสร้างโปรเจกต์เล็ก ๆ ก่อน เช่น API สำหรับดึงข้อมูลราคาทองคำหรืออัตราแลกเปลี่ยน แล้วค่อยขยายไปยังระบบที่ซับซ้อนขึ้น การเรียนรู้ผ่านการทำจริงจะช่วยให้เข้าใจ concepts ต่าง ๆ ได้ดีกว่าการอ่านเอกสารเพียงอย่างเดียว

ใช้กับ Docker ได้ไหม

ได้ครับ มี official Docker image สำหรับ Node.js ที่รองรับ TypeScript และ tRPC แนะนำให้ใช้ Docker สำหรับ development environment เพื่อความสม่ำเสมอ และใช้ Docker Compose หรือ Kubernetes สำหรับ production environment การ containerize application จะช่วยให้ deployment ง่ายและ reproducible

ต้องใช้ server spec เท่าไหร่

สำหรับ development ขั้นต่ำ 2 CPU, 4GB RAM, 50GB SSD ก็เพียงพอ สำหรับ production แนะนำ 2+ CPU, 64+ GB RAM, 200+ GB NVMe SSD ขึ้นอยู่กับปริมาณ traffic และจำนวน users ที่คาดหวัง หากใช้ cloud provider อย่าง AWS แนะนำเริ่มต้นด้วย instance t3.medium หรือสูงกว่า

มี GUI สำหรับจัดการไหม

tRPC เองเป็น library สำหรับ backend แต่สามารถใช้ Grafana Dashboard สำหรับ monitoring และ Portainer สำหรับ Docker management ได้ สำหรับ API testing แนะนำให้ใช้ Swagger UI หรือ Postman ซึ่งสามารถ generate documentation จาก tRPC router ได้อัตโนมัติ

ใช้ Cloud provider ไหนดี

ขึ้นอยู่กับงบประมาณและความต้องการ AWS มี service ครบถ้วนที่สุด GCP ดีสำหรับ Kubernetes และ machine learning DigitalOcean/Vultr ราคาถูกเหมาะกับ startup สำหรับผู้ใช้ในประเทศไทย แนะนำ DigitalOcean Singapore region เนื่องจาก latency ต่ำ หรือใช้ AWS ap-southeast-1 (Singapore) หากต้องการ service ที่ครบถ้วน

แนะนำเพิ่มเติม

🎯 เปิดบัญชี XM Forex → สมัคร

📱 แอป iCafeFX → ดาวน์โหลด

📊 สัญญาณฟรี → รับสัญญาณ

📚 คู่มือเทรด → SiamCafeBook

🤝 สมัคร Partner XM → pipaffiliates.com/c?c=72816&l=th&p=6

คู่มือ Forex ที่เกี่ยวข้อง

อ
XM Legend · เทรดเดอร์ & ผู้สอน Forex 13 ปี

ผู้ก่อตั้ง SiamCafe ตั้งแต่ปี 1997 · เทรดเดอร์สาย Forex มากกว่า 13 ปี ได้รับการยกย่องเป็น XM Legend · แบ่งปันความรู้ Forex, ไอที, AI และการเทรด จากประสบการณ์จริงในตลาดจริง

แหล่งอ้างอิง

  • SiamCafe.net - ชุมชนไอทีไทยตั้งแต่ปี 1997
  • iCafeFX.com - ศูนย์วิเคราะห์ Forex และทองคำ