text clean up
This commit is contained in:
@@ -7,9 +7,6 @@ let pool = null;
|
||||
* Uses connection pooling optimized for Lambda:
|
||||
* - Reuses connections across invocations (when container is warm)
|
||||
* - Small pool size to avoid exhausting database connections
|
||||
*
|
||||
* Expects DATABASE_URL environment variable in format:
|
||||
* postgresql://user:password@host:port/database
|
||||
*/
|
||||
function getPool() {
|
||||
if (!pool) {
|
||||
@@ -51,22 +48,26 @@ async function query(text, params) {
|
||||
const result = await pool.query(text, params);
|
||||
const duration = Date.now() - start;
|
||||
|
||||
console.log(JSON.stringify({
|
||||
level: "debug",
|
||||
message: "Executed query",
|
||||
query: text.substring(0, 100),
|
||||
duration,
|
||||
rows: result.rowCount,
|
||||
}));
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
level: "debug",
|
||||
message: "Executed query",
|
||||
query: text.substring(0, 100),
|
||||
duration,
|
||||
rows: result.rowCount,
|
||||
}),
|
||||
);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify({
|
||||
level: "error",
|
||||
message: "Query failed",
|
||||
query: text.substring(0, 100),
|
||||
error: error.message,
|
||||
}));
|
||||
console.error(
|
||||
JSON.stringify({
|
||||
level: "error",
|
||||
message: "Query failed",
|
||||
query: text.substring(0, 100),
|
||||
error: error.message,
|
||||
}),
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user