-
Notifications
You must be signed in to change notification settings - Fork 0
installation
Azizul Hakim edited this page Nov 1, 2024
·
2 revisions
Before installing nestjs-xsecurity, ensure you have:
- Node.js (v14 or higher)
- A NestJS project (v9 or higher)
- Package manager (npm, yarn, or pnpm)
# Using npm
npm install nestjs-xsecurity
# Using yarn
yarn add nestjs-xsecurity
# Using pnpm
pnpm add nestjs-xsecurity
Check your package.json
dependencies:
{
"dependencies": {
"nestjs-xsecurity": "^x.x.x"
}
}
After installing the package, you can choose between automated or manual setup.
Run our CLI tool to automatically set up configuration:
npx nestjs-xsecurity install
This command will:
- Generate a secure random secret
- Set up required environment variables
- Create an initial configuration file or update the existing
.env
If you prefer manual configuration:
- Generate a secure secret:
# Using node
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# Using openssl
openssl rand -base64 32
- Create or update your
.env
file with the generated secret:
# Required
XSECURITY_SECRET=your-generated-secret-key
# Optional (with defaults)
XSECURITY_ENABLED=true
XSECURITY_MAX_ATTEMPTS=5
XSECURITY_DECAY_MINUTES=1
- Follow the Quick Start Guide to implement the security middleware
- Check Configuration Options for available settings
- Read Security Best Practices for security recommendations
If you encounter installation issues:
- Clear your package manager cache and try reinstalling
- Verify Node.js and NestJS versions
- Check for conflicting dependencies
Copyright 2024, @AHS12 All Right Reserved