Initial Commit
Commit pertama, memindahkan repository dari github ke gitea.
This commit is contained in:
commit
13a47fbebf
41 files changed
+12327
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import mysql from "mysql2/promise";
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line no-var
|
||||
var mysqlPool: mysql.Pool | undefined;
|
||||
}
|
||||
|
||||
const pool =
|
||||
global.mysqlPool ||
|
||||
mysql.createPool({
|
||||
host: process.env.DB_HOST || "103.155.224.244",
|
||||
port: Number(process.env.DB_PORT) || 3306,
|
||||
user: process.env.DB_USER || "root",
|
||||
password: process.env.DB_PASSWORD || "hqn9OY2pJx1oYRYJoVrC0Q64sZj8k3W3ZpoVcsKAmv1DFqO9u0DIMGCkjjXEjLaB",
|
||||
database: process.env.DB_NAME || "aghatis_studio_db",
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0,
|
||||
connectTimeout: 10000,
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
global.mysqlPool = pool;
|
||||
}
|
||||
|
||||
export default pool;
|
||||
|
||||
export async function query<T = unknown>(sql: string, params?: unknown[]): Promise<T> {
|
||||
const [rows] = await pool.query(sql, params);
|
||||
return rows as T;
|
||||
}
|
||||
Reference in new issue
Block a user