This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* parameters for both functions: | |
* 1. isOverTheLimit | |
* 2. addRequestToRateLimitWndow | |
* | |
* is a key, which represents the key on which the rate limiter should be working. | |
* e.g. | |
* 1. if you want to rate limit a specific api, say, /v1/api then key is simply : `/v1/api` | |
* 2. if you want to rate limit a specific api and IP address, then key can a combination of both viz.: `/v1/api:34.10.43.23` | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pgp = require('pg-promise')(); | |
pgp.pg.types.setTypeParser(20, parseInt); | |
function AggregateQuery(queryBuilders) { | |
// pass in a knex transaction | |
async function run(transaction) { | |
const queries = queryBuilders.map(qb => { | |
const { sql: query, bindings: values } = qb.toSQL().toNative(); | |
return { query, values }; | |
}); |