42 lines
1.2 KiB
Plaintext
42 lines
1.2 KiB
Plaintext
/my-api-v2
|
|
├── .env # 環境變數 (DB 帳密, Mail 帳密)
|
|
├── server.js # 主程式 (Entry Point)
|
|
├── src/
|
|
│ ├── config/
|
|
│ │ └── db.js # MariaDB 連線池設定
|
|
│ ├── services/
|
|
│ │ ├── ormService.js # 核心 ORM 與 SP 邏輯
|
|
│ │ ├── uploadService.js # 檔案上傳邏輯
|
|
│ │ └── mailService.js # 郵件與排程邏輯
|
|
│ └── utils/
|
|
│ └── helper.js # 通用工具函式 (quotstr, date format)
|
|
└── public/upload # 檔案上傳目錄
|
|
|
|
>> https://gemini.google.com/app/57091040afbd48e1
|
|
|
|
|
|
# 1. 初始化 npm 專案 (若尚未執行)
|
|
npm init -y
|
|
|
|
# 2. 安裝核心 Web 框架與安全套件
|
|
npm install express cors helmet dotenv
|
|
|
|
# 3. 安裝資料庫驅動 (MariaDB/MySQL)
|
|
npm install mysql2
|
|
|
|
# 4. 安裝檔案處理與上傳套件
|
|
npm install multer
|
|
|
|
# 5. 安裝郵件與排程套件
|
|
npm install nodemailer node-schedule
|
|
|
|
# 6. 安裝進階 Log 管理系統
|
|
npm install morgan winston winston-daily-rotate-file
|
|
|
|
# 7. (選用) 安裝開發環境自動重啟工具
|
|
npm install --save-dev nodemon
|
|
|
|
|
|
|
|
|