Quickstart
Node.js and Express. About two minutes.
1Create a project and an API key
Sign up, create a project, and create an API key for your environment. Keep the key in an environment variable, never in your code.
2Install the SDK
npm install https://getfortress.co.uk/sdk/fortress-sdk-latest.tgz
Needs Node.js 22.5 or newer. The SDK has no dependencies. It is open source (MIT).
3Connect your app
import express from "express";
import { Fortress } from "@fortress/sdk";
const fortress = new Fortress({
apiKey: process.env.FORTRESS_API_KEY,
environment: "production",
baseUrl: "https://getfortress.co.uk",
});
fortress.start(); // heartbeats, and crashes are reported automatically
const app = express();
app.use(express.json());
app.use(fortress.middleware()); // request monitoring
app.use(fortress.shield()); // attack protection, learning mode first
// ...your routes...
app.use(fortress.errorHandler()); // reports errors your routes throw
Open your project in the dashboard. Within a few seconds you will see your app's status, and in the Shield tab, any attacks it spots.
4Switch Shield to blocking
Shield starts in learning mode: it records what it would block and blocks nothing, so it can never lock out a real customer by surprise. When the Shield tab shows only real attacks, switch on blocking:
app.use(fortress.shield({ mode: "block" }));
It refuses SQL injection, script injection, path traversal, command injection, scanner probes (/.env, /wp-login.php), attack tools, request floods and password guessing. It fails open: if Shield itself ever breaks, requests pass through. See it work on a pretend shop in the live demo.
5Retry flaky services and keep going when one is down
const items = await fortress.resilient("recommendations", () => recsApi.fetch(userId), {
retries: 2,
timeoutMs: 3000,
fallback: () => [], // shown instead of an error page
});
Failing calls are retried. If one keeps failing, your fallback answers instantly for 30 seconds instead of every visitor waiting on a dead service, then one trial call checks whether it is back. Without a fallback the original error is thrown, so nothing is hidden.
Not sure where to start?
Run the free website check on your site first. It takes a few seconds and needs no sign-up.