@riavzon/bot-detector-create 1.0.0 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +100 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # @riavzon/bot-detector-create
2
+
3
+ Zero-config setup for [@riavzon/bot-detector](https://github.com/Sergo706/botDetector).
4
+ Run one command and get a fully configured bot detection middleware with all
5
+ data sources downloaded, compiled, and a SQLite database ready to go.
6
+
7
+ ## Usage
8
+
9
+ Run this in the root of your Express project:
10
+
11
+ ```bash
12
+ npx @riavzon/bot-detector-create
13
+ ```
14
+
15
+ The command does the following in order:
16
+
17
+ 1. Installs `@riavzon/bot-detector`, `express`, `cookie-parser`, and
18
+ `better-sqlite3` into your project.
19
+ 2. Triggers the data source installer — downloads and compiles all threat
20
+ intelligence feeds (FireHOL, Tor, ASN, GeoIP, JA4, user-agent lists) into
21
+ fast local MMDB/LMDB files.
22
+ 3. Writes a `botDetectorConfig.ts` file at your project root with all 17
23
+ checkers pre-configured at their default values.
24
+ 4. Runs `load-schema` to create the `visitors` and `banned` tables in a local
25
+ `bot_detector.sqlite` file.
26
+
27
+ ## What you get
28
+
29
+ `botDetectorConfig.ts` is a fully annotated configuration file. Every option
30
+ is shown explicitly so you know exactly what's active and what you can tune.
31
+
32
+ ```ts
33
+ import { defineConfiguration } from '@riavzon/bot-detector';
34
+
35
+ await defineConfiguration({
36
+ store: {
37
+ main: {
38
+ driver: 'sqlite',
39
+ name: './bot_detector.sqlite',
40
+ },
41
+ },
42
+ // ... all 17 checkers with default penalties
43
+ });
44
+ ```
45
+
46
+ The defaults use SQLite and in-process memory cache — no external services
47
+ required. When you're ready for production, swap the adapters:
48
+
49
+ ```ts
50
+ // MySQL
51
+ store: { main: { driver: 'mysql-pool', host: '...', user: '...', ... } }
52
+
53
+ // Redis cache
54
+ storage: { driver: 'redis', url: process.env.REDIS_URL }
55
+
56
+ // Upstash (serverless)
57
+ storage: { driver: 'upstash', url: process.env.UPSTASH_URL, token: process.env.UPSTASH_TOKEN }
58
+ ```
59
+
60
+ ## Mount the middleware
61
+
62
+ Import `botDetectorConfig.ts` at the top of your app entry point, before any
63
+ routes, then mount the middleware:
64
+
65
+ ```ts
66
+ import './botDetectorConfig.js';
67
+ import { detectBots } from '@riavzon/bot-detector';
68
+ import cookieParser from 'cookie-parser';
69
+ import express from 'express';
70
+
71
+ const app = express();
72
+ app.use(cookieParser());
73
+ app.use(detectBots());
74
+
75
+ app.get('/', (req, res) => {
76
+ res.send('Hello, human.');
77
+ });
78
+
79
+ app.listen(3000);
80
+ ```
81
+
82
+ ## Keep data sources fresh
83
+
84
+ Threat intelligence feeds update continuously. Run a refresh at least once
85
+ every 24 hours:
86
+
87
+ ```bash
88
+ npx @riavzon/bot-detector refresh
89
+ ```
90
+
91
+ Add it to a cron job or a scheduled CI step to keep detection accurate.
92
+
93
+ ## Requirements
94
+
95
+ - Node.js 18 or later
96
+ - npm
97
+
98
+ ## License
99
+
100
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riavzon/bot-detector-create",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "author": "Sergio contact@riavzon.com",
6
6
  "license": "Apache-2.0",
@@ -25,7 +25,7 @@
25
25
  "detect bots"
26
26
  ],
27
27
  "bin": {
28
- "create-bot-detector": "./dist/create.mjs"
28
+ "create-bot-detector": "./dist/create.cjs"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "tsdown",
@@ -39,4 +39,4 @@
39
39
  "tsdown": "latest",
40
40
  "typescript": "latest"
41
41
  }
42
- }
42
+ }