Installation
Requirements
Section titled “Requirements”- Node.js >= 18 (ES2022 target)
- TypeScript >= 5.0 (recommended)
Core + Adapter
Section titled “Core + Adapter”Install the adapter package for your framework. Each adapter includes @guardcore/core as a dependency.
Express
Section titled “Express”npm install @guardcore/expresspnpm add @guardcore/expressyarn add @guardcore/expressbun add @guardcore/expressFastify
Section titled “Fastify”npm install @guardcore/fastifypnpm add @guardcore/fastifyyarn add @guardcore/fastifybun add @guardcore/fastifyNestJS
Section titled “NestJS”npm install @guardcore/nestjspnpm add @guardcore/nestjsyarn add @guardcore/nestjsbun add @guardcore/nestjsnpm install @guardcore/honopnpm add @guardcore/honoyarn add @guardcore/honobun add @guardcore/honoOptional Peer Dependencies
Section titled “Optional Peer Dependencies”These are all optional. Install them to enable specific features.
| Package | Feature | Required for |
|---|---|---|
ioredis | Redis client | Distributed rate limiting, IP bans, caching |
re2-wasm | ReDoS-safe regex | Safe pattern matching on untrusted input |
maxmind | GeoIP lookups | Country-based filtering (blockedCountries, whitelistCountries) |
he | HTML entity decoding | Enhanced content preprocessing in detection engine |
acorn | JS AST parsing | Code injection risk scoring in semantic analyzer |
# Redis supportpnpm add ioredis
# ReDoS-safe regex (recommended for production)pnpm add re2-wasm
# GeoIP country filteringpnpm add maxmindAll features gracefully degrade when their peer dependency is not installed:
- Without
ioredis: rate limiting and IP bans use in-memory storage - Without
re2-wasm: falls back to nativeRegExpwithworker_threadstimeout protection - Without
maxmind: country-based filtering is unavailable (you can still provide a customgeoResolver)
CORS Packages
Section titled “CORS Packages”CORS integration requires a framework-specific CORS package:
| Adapter | CORS Package |
|---|---|
@guardcore/express | cors |
@guardcore/fastify | @fastify/cors |
@guardcore/hono | Built-in (hono/cors) |
@guardcore/nestjs | Use Express CORS or @nestjs/platform-express |