cyber-shield-express
v1.0.2
Published
CyberShield WAF Agent for Express.js — Real-time web application firewall powered by MERN Cloud AI engine. Protects against SQL injection, XSS, brute-force, and more.
Readme
CyberShield WAF Plugin for Express.js
CyberShield WAF Plugin is a real-time web application firewall (WAF) middleware for Express.js applications. Powered by the MERN Cloud AI engine, it provides robust protection against common web vulnerabilities
Installation
You can install the CyberShield Plugin via npm or yarn.
Using npm
npm install cyber-shield-expressUsing yarn
yarn add cyber-shield-expressNote: This package requires Node.js
14.0.0or higher and Express4.0.0or higher.
Basic Usage
To integrate the CyberShield WAF into your Express application, simply import the agent, initialize it with your configuration credentials, and add it as a middleware.
import cyberShield from "cyber-shield-express";
const app = express();
// 1. Initialize CyberShield Agent
cyberShield.init({
apiKey: process.env.CYBERSHIELD_API_KEY,
siteUrl: process.env.CYBERSHIELD_SITE_URL,
emailAddress: process.env.CYBERSHIELD_EMAIL,
});
// 2. Attach the WAF middleware globally
// Ensure you place this BEFORE your route definitions so requests are scanned.
app.use(cyberShield.waf);
// Example route
app.get('/', (req, res) => {
res.send('Your application is protected by CyberShield!');
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});Environment Variables
All credentials must be stored in a .env file at the root of your project — never hardcoded in source code.
1. Install dotenv
npm install dotenv2. Create a .env file
# .env (never commit this file — add it to .gitignore)
CYBERSHIELD_API_KEY=your_cybershield_api_key
CYBERSHIELD_SITE_URL=https://your-domain.com
[email protected]
CYBERSHIELD_API_URL=https://your-mern-engine-url.com3. Load .env at the very top of your entry file
require('dotenv').config(); // Must be the FIRST line
const express = require('express');
const cyberShield = require('cyber-shield-express');Important: Add
.envto your.gitignoreto prevent secrets from being committed.
# .gitignore
.envConfiguration Options
When calling cyberShield.init(config), you can pass the following properties in the config object:
| Option | Type | Required | Description |
|--------|------|----------|-------------|
| apiKey | string | Yes | Your unique CyberShield API Key. |
| siteUrl | string | Yes | The base URL of the site being protected. |
| emailAddress | string | Yes | Administrator email address for alert notifications. |
Support & Issues
For issues and feature requests, please visit the GitHub repository or contact SECURAS.
