|
@@ -3,8 +3,9 @@ import mysql from 'mysql2/promise';
|
|
|
|
|
|
|
|
// 创建全局的 MySQL 连接池
|
|
// 创建全局的 MySQL 连接池
|
|
|
const pool = mysql.createPool({
|
|
const pool = mysql.createPool({
|
|
|
- connectionLimit: 10,
|
|
|
|
|
|
|
+ connectionLimit: 100,
|
|
|
host: 'xia0miduo.gicp.net', // 服务器地址
|
|
host: 'xia0miduo.gicp.net', // 服务器地址
|
|
|
|
|
+ port: 3306,
|
|
|
user: 'root',
|
|
user: 'root',
|
|
|
password: '123456', // 密码
|
|
password: '123456', // 密码
|
|
|
database: 'chat',
|
|
database: 'chat',
|
|
@@ -20,7 +21,7 @@ interface Request {
|
|
|
}[];
|
|
}[];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export async function insertData(req: Request) {
|
|
|
|
|
|
|
+export async function POST(req: Request) {
|
|
|
try {
|
|
try {
|
|
|
// 从连接池中获取连接
|
|
// 从连接池中获取连接
|
|
|
const connection = await pool.getConnection()
|
|
const connection = await pool.getConnection()
|
|
@@ -56,7 +57,7 @@ export async function insertData(req: Request) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export async function getAllData() {
|
|
|
|
|
|
|
+export async function GET() {
|
|
|
try {
|
|
try {
|
|
|
// 从连接池中获取连接
|
|
// 从连接池中获取连接
|
|
|
const connection = await pool.getConnection()
|
|
const connection = await pool.getConnection()
|