Compare commits
2 Commits
d7c1c0ae5c
...
bff665c6ec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bff665c6ec | ||
|
|
c7111329dc |
@@ -27,7 +27,7 @@
|
|||||||
"require-await": "off",
|
"require-await": "off",
|
||||||
"no-param-reassign": ["error", {
|
"no-param-reassign": ["error", {
|
||||||
"props": true,
|
"props": true,
|
||||||
"ignorePropertyModificationsFor": ["state", "acc", "req"]
|
"ignorePropertyModificationsFor": ["state", "acc", "req", "error"]
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
"globals": {
|
"globals": {
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.250.36",
|
"version": "1.250.37",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.250.36",
|
"version": "1.250.37",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.458.0",
|
"@aws-sdk/client-s3": "^3.458.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.250.36",
|
"version": "1.250.37",
|
||||||
"description": "All the latest porn releases in one place",
|
"description": "All the latest porn releases in one place",
|
||||||
"main": "src/app.js",
|
"main": "src/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
22
src/knex.js
22
src/knex.js
@@ -3,7 +3,7 @@
|
|||||||
const config = require('config');
|
const config = require('config');
|
||||||
const knex = require('knex');
|
const knex = require('knex');
|
||||||
|
|
||||||
module.exports = knex({
|
const knexInstance = knex({
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: config.database.owner,
|
connection: config.database.owner,
|
||||||
pool: config.database.pool,
|
pool: config.database.pool,
|
||||||
@@ -11,3 +11,23 @@ module.exports = knex({
|
|||||||
asyncStackTraces: process.env.NODE_ENV === 'development',
|
asyncStackTraces: process.env.NODE_ENV === 'development',
|
||||||
// debug: process.env.NODE_ENV === 'development',
|
// debug: process.env.NODE_ENV === 'development',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
knexInstance.on('query', function onQuery(query) {
|
||||||
|
const bindingCount = query.bindings?.length ?? 0;
|
||||||
|
|
||||||
|
if (bindingCount > 10000) {
|
||||||
|
const error = new Error(`[knex] Dangerous query: ${bindingCount} bindings detected: ${query.sql?.slice(0, 200)}${query.sql?.length > 200 ? '...' : ''}`);
|
||||||
|
|
||||||
|
Error.captureStackTrace(error, onQuery);
|
||||||
|
// console.error(error);
|
||||||
|
|
||||||
|
throw error; // optionally hard-fail so you get a real stack trace
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
knexInstance.on('query-error', (error, query) => {
|
||||||
|
error.knexSql = `${query.sql?.slice(0, 200)}${query.sql?.length > 200 ? '...' : ''}`;
|
||||||
|
error.knexBindingCount = query.bindings?.length;
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = knexInstance;
|
||||||
|
|||||||
15
src/tools/huge-query.js
Normal file
15
src/tools/huge-query.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const knex = require('../knex');
|
||||||
|
|
||||||
|
async function init() {
|
||||||
|
const data = Array.from({ length: 100_000 }, (value, index) => ({
|
||||||
|
id: `test_affiliate_${index}`,
|
||||||
|
}));
|
||||||
|
|
||||||
|
await knex('affiliates').insert(data);
|
||||||
|
|
||||||
|
console.log('Done!');
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
Reference in New Issue
Block a user