Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Rossen27 committed Apr 30, 2024
1 parent d67e920 commit 2c091b6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 47 deletions.
38 changes: 38 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
NODE_ENV=PRODUCTION
FRONTEND_URL=http://localhost:4000

DB_URI=mongodb+srv://rossen:[email protected]/RossenHua?retryWrites=true&w=majority&appName=Cluster0

# 設定令牌,dsadasdas可自訂
JWT_SECRET=dsadasdas
# 設定令牌有效時間:1天 1d ,10分鐘 10
JWT_EXPIRES_TIME=5d

# cookie 有效期,預設 7 天
COOKIE_EXPIRES_TIME=7

# Email設定
SMTP_HOST=sandbox.smtp.mailtrap.io
SMTP_PORT=2525
SMTP_EMAIL=1e11c2033d3f2f
SMTP_PASSWORD=3bc1ef7459e3e9
SMTP_FROM_EMAIL=[email protected]
SMTP_FROM_NAME=ShopIT

# 雲端空間
CLOUDINARY_CLOUD_NAME=shopit-v1
CLOUDINARY_API_KEY=344946393492773
CLOUDINARY_API_SECRET=1_5_za_-ZqNGW5Voil5bhdaPxvs

# FireBase
FIREBASE_API_KEY=AIzaSyDosEHvdbq_7YOuz3xrsh-fHpnifnNEnyQ
FIREBASE_AUTH_DOMAIN=shopit-v1-c66ae.firebaseapp.com
FIREBASE_PROJECT_ID=shopit-v1-c66ae
FIREBASE_STORAGE_BUCKET=shopit-v1-c66ae.appspot.com
FIREBASE_MESSAGING_SENDER_ID=841693456845
FIREBASE_APP_ID=1:841693456845:web:6b75728f98b61ac0febc84
FIREBASE_MEASUREMENT_ID=G-MMSH808DRS

# 使用 Stripe 的密鑰
STRIPE_SECRET_KET=sk_test_51P61snCq5oWqyU7ye5yk89wPl0CquinSnlYOqsrDgKpHPJvoiMrZUqTfj33deHwkdbWOc59FcO6ngA3nwbcQPj9p006rt539zt
STRIPE_WEBHOOK_SECRET=whsec_e7ba86765202fa5c3f3e0e46e69eb686717541b697d10b0115202f5a54848f98
25 changes: 12 additions & 13 deletions backend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ process.on("uncaughtException", (err) => {

// 設定 .env 檔案的路徑
if (process.env.NODE_ENV !== "PRODUCTION") {
dotenv.config({ path: "backend/config/config.env" }); // 使用 dotenv.config() 方法,並指定 .env 檔案的路徑
dotenv.config({ path: "backend/config/config.env" });
}
// dotenv.config({ path: "backend/config/config.env" });

// 引入資料庫連接模組
connectDatabase();

Expand All @@ -32,15 +34,15 @@ app.use(
},
})
); // 使用 express.json() 中介軟體,以解析請求主體中的 JSON 資料 (這裡是解析 req.body) 並設定限制大小為 10mb
app.use(
express.urlencoded({
limit: "10mb",
verify: (req, res, buf) => {
req.rawBody = buf.toString(); // 使用 req.rawBody 取得請求主體中的原始資料
},
extended: true,
})
);
// app.use(
// express.urlencoded({
// limit: "10mb",
// verify: (req, res, buf) => {
// req.rawBody = buf.toString(); // 使用 req.rawBody 取得請求主體中的原始資料
// },
// extended: true,
// })
// );
app.use(cookieParser()); // 使用 cookieParser() 中介軟體,以解析請求中的 cookie

// 設定路由
Expand All @@ -56,9 +58,6 @@ app.use("/api/v1", paymentRoutes); // 使用付款路由

if (process.env.NODE_ENV === "PRODUCTION") {
app.use(express.static(path.join(__dirname, "../frontend/dist"))); // 使用 express.static() 中介軟體,以提供靜態檔案 (這裡是提供前端檔案)

// file deepcode ignore NoRateLimitingForExpensiveWebOperation: <please specify a reason of ignoring this>
// deepcode ignore NoRateLimitingForExpensiveWebOperation: <please specify a reason of ignoring this>
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "frontend","dist","index.html")); // 使用 res.sendFile() 方法,以發送檔案 (這裡是發送 index.html)
});
Expand Down
2 changes: 1 addition & 1 deletion backend/config/config.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PORT=4000
NODE_ENV=PRODUCTION
NODE_ENV=DEVELOPMENT
FRONTEND_URL=http://localhost:8080

DB_LOCAL_URI=mongodb://127.0.0.1:27017/shopit-v1
Expand Down
33 changes: 0 additions & 33 deletions workflows/firebase.yml

This file was deleted.

0 comments on commit 2c091b6

Please sign in to comment.