{"id":51161098,"url":"https://github.com/tryghost/brute-knex","last_synced_at":"2026-06-26T14:00:27.227Z","repository":{"id":367317869,"uuid":"1211251083","full_name":"TryGhost/brute-knex","owner":"TryGhost","description":"Knex for Express-Brute","archived":false,"fork":false,"pushed_at":"2026-06-25T14:12:48.000Z","size":91,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-25T14:13:23.022Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TryGhost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"tryghost","open_collective":"ghost"}},"created_at":"2026-04-15T07:55:48.000Z","updated_at":"2026-06-25T14:09:32.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/TryGhost/brute-knex","commit_stats":null,"previous_names":["tryghost/brute-knex"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/TryGhost/brute-knex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TryGhost%2Fbrute-knex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TryGhost%2Fbrute-knex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TryGhost%2Fbrute-knex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TryGhost%2Fbrute-knex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TryGhost","download_url":"https://codeload.github.com/TryGhost/brute-knex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TryGhost%2Fbrute-knex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34819597,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-26T02:00:06.560Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-26T14:00:16.634Z","updated_at":"2026-06-26T14:00:27.216Z","avatar_url":"https://github.com/TryGhost.png","language":"JavaScript","funding_links":["https://github.com/sponsors/tryghost","https://opencollective.com/ghost"],"categories":[],"sub_categories":[],"readme":"# @tryghost/brute-knex\n\nKnex-backed store for [express-brute](https://github.com/AdamPflug/express-brute) that persists rate-limit state in SQL databases.\n\n## What It Does\n\n`@tryghost/brute-knex` lets `express-brute` share brute-force counters through a Knex table instead of keeping them in process memory. It can create its storage table automatically, use a caller-provided Knex instance, or fall back to a local SQLite database when no Knex instance is supplied.\n\nThe package supports Node.js `\u003e=20.20.0`. CI exercises the store against SQLite, MySQL, and Postgres, with additional MySQL coverage for existing consumers that provide Knex `0.21.6`.\n\n## Installation\n\nInstall the package and the Knex database driver your app uses:\n\n```sh\nnpm install @tryghost/brute-knex knex mysql2\n```\n\nUse `pg` instead of `mysql2` for Postgres, or `sqlite3` for SQLite.\n\n## Usage\n\n```js\nconst ExpressBrute = require('express-brute');\nconst Knex = require('knex');\nconst BruteKnex = require('@tryghost/brute-knex');\n\nconst knex = Knex({\n    client: 'mysql2',\n    connection: {\n        host: '127.0.0.1',\n        user: 'root',\n        password: 'root',\n        database: 'brute_knex'\n    }\n});\n\nconst store = new BruteKnex({\n    knex,\n    tablename: 'brute'\n});\n\nconst bruteforce = new ExpressBrute(store, {\n    freeRetries: 2\n});\n```\n\nSee [example.js](example.js) for a complete Express route.\n\n## Options\n\n- `tablename`: table name for brute-force records. Defaults to `brute`.\n- `knex`: Knex instance to use. If omitted, `brute-knex` creates a SQLite database at `./brute-knex.sqlite`.\n- `createTable`: set to `false` when the table already exists and should not be created automatically.\n\nThe table stores `key`, `firstRequest`, `lastRequest`, `lifetime`, and `count` columns. Timestamps are stored as UTC millisecond values.\n\n## Development\n\nThis repo uses the organisation default Node.js `22` for local development through `.nvmrc`, and pnpm `10.x` through Corepack. Package support still starts at Node.js `20.20.0` for existing consumers.\n\n```sh\ncorepack enable\npnpm install --frozen-lockfile\npnpm test\npnpm lint\n```\n\nDatabase-specific test commands:\n\n```sh\npnpm run test:e2e:sqlite\npnpm run test:e2e:mysql\npnpm run test:e2e:postgres\n```\n\nThe MySQL and Postgres commands expect local test databases unless they are running inside the GitHub Actions service containers. The test suite reads standard connection env vars such as `MYSQL_HOST`, `MYSQL_DATABASE`, `POSTGRES_HOST`, and `POSTGRES_DB`.\n\n## Releasing\n\nReleases are handled by [`@tryghost/pro-ship`](https://www.npmjs.com/package/@tryghost/pro-ship):\n\n```sh\npnpm ship\n```\n\nThe `ship` script bumps the version, creates the release commit and tag, pushes them, and publishes `@tryghost/brute-knex` to npm.\n\n## Copyright \u0026 License\n\nCopyright (c) 2014, llambda \u003cxxgsoftware@gmail.com\u003e.\nReleased under the [ISC license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryghost%2Fbrute-knex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftryghost%2Fbrute-knex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryghost%2Fbrute-knex/lists"}