修改接口

This commit is contained in:
董海洋
2026-05-26 09:30:17 +08:00
parent ff40282dc1
commit 55452a2d21
9 changed files with 147 additions and 24 deletions
+13 -4
View File
@@ -1,17 +1,26 @@
const fs = require('fs')
const path = require('path')
const mysql = require('mysql2/promise')
require('dotenv').config({ path: path.join(__dirname, '../.env') })
const categoriesData = require('../data/categories.json')
const goodsData = require('../data/goods.json')
const usersData = require('../data/users.json')
function requireEnv(name, fallback) {
const value = process.env[name] || fallback
if (!value && !fallback) {
throw new Error(`Missing ${name} in .env`)
}
return value
}
const config = {
host: '110.42.255.239',
port: 3306,
host: requireEnv('DB_HOST'),
port: parseInt(requireEnv('DB_PORT', '3306')),
user: 'root',
password: 'Wentian9588.',
database: 'miniprogram'
password: requireEnv('DB_ROOT_PASSWORD'),
database: requireEnv('DB_NAME', 'miniprogram')
}
async function run() {