53 lines
1.1 KiB
Plaintext
53 lines
1.1 KiB
Plaintext
🚀 PART 1 : สร้างโปรเจ็กต์หลัก
|
|
📁 1. เปิดโฟลเดอร์หลักของระบบ
|
|
E:\Skyz\micro-service-api
|
|
📦 2. สร้างไฟล์หลัก
|
|
mkdir shared
|
|
mkdir gateway-api
|
|
mkdir exthernal-mobile-api
|
|
|
|
🧱 PART 2 : ติดตั้ง Node.js โปรเจกต์
|
|
🌐 1. สร้าง package.json ในแต่ละ service
|
|
|
|
|
|
cd gateway-api
|
|
npm init -y
|
|
cd ../exthernal-mobile-api
|
|
npm init -y
|
|
|
|
|
|
📦 2. ติดตั้ง dependencies หลัก
|
|
npm install express pg cors dotenv
|
|
|
|
npm install express-session connect-redis ioredis
|
|
|
|
npm install --save-dev nodemon
|
|
|
|
npm install -g nodemon
|
|
|
|
npm install jsonwebtoken
|
|
|
|
ติดตั้ง Redis
|
|
|
|
|
|
|
|
|
|
✏️ 3. เพิ่ม script ใน package.json
|
|
"scripts": {
|
|
"start": "node src/app.js",
|
|
"dev": "nodemon src/app.js"
|
|
}
|
|
|
|
|
|
|
|
|
|
⚙️ วิธีรันแต่ละ service
|
|
|
|
จาก root (micro-service-api):
|
|
|
|
# เริ่มโปรแกรมหลัก
|
|
npm run dev
|
|
|
|
# หรือเริ่มเฉพาะ API ย่อย
|
|
npm run start:mobile
|
|
npm run start:wep |