feat: modernized web application
This commit is contained in:
23
nextjs/src/lib/db.ts
Normal file
23
nextjs/src/lib/db.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import mysql from 'mysql2/promise';
|
||||
|
||||
function createPool(): mysql.Pool {
|
||||
const port = process.env.DB_PORT ? parseInt(process.env.DB_PORT, 10) : 3306;
|
||||
return mysql.createPool({
|
||||
connectionLimit: 10,
|
||||
port,
|
||||
host: process.env.DB_ENDPOINT,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASS,
|
||||
database: 'catherine_league',
|
||||
charset: 'utf8mb4',
|
||||
});
|
||||
}
|
||||
|
||||
let pool: mysql.Pool | undefined;
|
||||
|
||||
export function getPool(): mysql.Pool {
|
||||
if (!pool) {
|
||||
pool = createPool();
|
||||
}
|
||||
return pool;
|
||||
}
|
||||
Reference in New Issue
Block a user