From adc9f2259ee1de1baeb64cf7503c98262bd0a8cc Mon Sep 17 00:00:00 2001 From: LingandRX Date: Sun, 5 Jan 2025 18:46:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor(config):=20=E4=BC=98=E5=8C=96=20MongoD?= =?UTF-8?q?B=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 替换 dotenv 引入方式,使用 destructuring 导入 config 函数- 调用 config()函数以加载环境变量 -移除冗余的 import('dotenv').config() 语句 --- config/mongodbConfig.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/mongodbConfig.js b/config/mongodbConfig.js index b33676a..f966f93 100644 --- a/config/mongodbConfig.js +++ b/config/mongodbConfig.js @@ -1,7 +1,9 @@ import mongoose from 'mongoose' import logger from 'morgan' -import('dotenv').config() +import { config } from 'dotenv' + +config() // 使用环境变量存储敏感信息 const account = process.env.MONGO_ACCOUNT