Development Setup Getting Started
Prerequisites
Important
Before setting up the CS2Inspect development environment, ensure you have the following installed:
Required Software
Node.js: Version 16.x or higher (18.x recommended) Required
bashnode --version # Should be v16.0.0 or highernpm: Version 8.x or higher (comes with Node.js) Required
bashnpm --versionMariaDB/MySQL: Version 10.x or higher Required
- Alternative: Docker (for containerized database)
Git: Latest version Required
bashgit --version
Optional Software
- Docker & Docker Compose: For containerized development Recommended
- Visual Studio Code: Recommended IDE with extensions:
- Volar (Vue Language Features)
- ESLint
- Tailwind CSS IntelliSense
- TypeScript Vue Plugin
Installation Steps
1. Clone the Repository
git clone https://github.com/sak0a/cs2inspect-web.git
cd cs2inspect-web2. Install Dependencies
npm installWhat gets installed?
This will install all required packages including:
- Nuxt 3 framework
- Vue 3 and TypeScript
- Naive UI components
- Tailwind CSS
- Database drivers
- Testing frameworks
- And more...
3. Database Setup
Option A: Using Docker (Recommended for Development) Recommended
# Start MariaDB container
docker-compose up -d
# This will:
# - Start MariaDB on port 3306
# - Create database 'csinspect'
# - Set root password from .env fileOption B: Using Local MariaDB/MySQL
Install MariaDB:
bash# Ubuntu/Debian sudo apt-get install mariadb-server # macOS brew install mariadb # Windows # Download from https://mariadb.org/download/Start MariaDB:
bashsudo systemctl start mariadbCreate Database:
bashmysql -u root -psqlCREATE DATABASE csinspect CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'csinspect'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON csinspect.* TO 'csinspect'@'localhost'; FLUSH PRIVILEGES; EXIT;Database Schema:
Automatic Migrations
The application now uses automatic database migrations. You no longer need to manually import the schema. The migrations will run automatically when you start the server for the first time.
If you prefer to manually initialize the database:
bashmysql -u csinspect -p csinspect < server/database/migrations/000_initial.sqlThe migration system will:
- Create all required tables automatically
- Track applied migrations in the
_migrationstable - Run any new migrations on subsequent starts
- Skip already-applied migrations
4. Environment Configuration
Copy the example environment file:
bashcp .env.example .envEdit
.envfile with your configuration:Security Notice
Make sure to generate a secure JWT token and use strong passwords for production!
env########## Server Configuration ########## PORT=3000 HOST=127.0.0.1 ########## JWT API Configuration ########## # Generate a random secret key JWT_TOKEN=your_random_secret_key_here_min_32_characters JWT_EXPIRY=7d ########## Database Configuration ########## DATABASE_HOST=127.0.0.1 DATABASE_PORT=3306 DATABASE_USER=csinspect DATABASE_PASSWORD=your_database_password DATABASE_NAME=csinspect DATABASE_CONNECTION_LIMIT=5 ########## Steam API Configuration ########## # Get your Steam API key: https://steamcommunity.com/dev/apikey STEAM_API_KEY=your_steam_api_key_here ########## Steam Account Configuration (Optional) ########## # Required for unmasked inspect URLs # Use a separate Steam account (Steam Guard not currently supported) STEAM_USERNAME=your_steam_username STEAM_PASSWORD=your_steam_password ########## Logging (Optional) ########## LOG_API_REQUESTS=trueGenerate a secure JWT token:
bash# Using Node.js node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" # Or using OpenSSL openssl rand -hex 32
5. Verify Configuration
Check that your configuration is correct:
# Test database connection
npm run db:test
# Or manually test:
mysql -h 127.0.0.1 -u csinspect -p csinspect -e "SHOW TABLES;"Running the Application
Development Mode
Start the development server with hot-reload:
npm run devThe application will be available at:
- Local: http://localhost:3000
- Network: http://YOUR_IP:3000
- Health Status: http://localhost:3000/status
First Startup:
- Database migrations run automatically
- Health check sampling starts automatically
- Check console for migration progress
- Monitor startup health at
/api/health/details
Production Build
Build the application for production:
npm run buildPreview the production build:
npm run previewDocker Development
Run the entire stack with Docker Compose:
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose downDatabase Management
Automatic Migrations
The project now uses an automatic migration system. Migrations run on server startup.
How it works:
- Migrations stored in
server/database/migrations/ - Executed sequentially on startup (000_, 001_, 002_, etc.)
- Tracked in
_migrationstable - Skips already-applied migrations
- Safe to re-run (idempotent operations)
Available Migrations:
000_initial.sql- Initial database schema (base tables)001_add_health_checks.sql- Health monitoring tables
No manual intervention required - migrations run automatically!
Manual Migration (if needed):
# Apply specific migration
mysql -u csinspect -p csinspect < server/database/migrations/000_initial.sql
# Or apply all in order
for file in server/database/migrations/*.sql; do
echo "Applying: $file"
mysql -u csinspect -p csinspect < "$file"
doneCreating New Migrations:
- Create file:
002_your_description.sql - Use sequential numbering
- Use
IF NOT EXISTSfor tables/indexes - Document in
server/database/migrations/README.md - Restart server - migration runs automatically
Backup database:
mysqldump -u csinspect -p csinspect > backup_$(date +%Y%m%d).sqlRestore database:
mysql -u csinspect -p csinspect < backup_20240101.sqlDatabase Schema
The main tables are:
# Core Application Tables
wp_player_loadouts - User loadout configurations
wp_player_weapons - Weapon customizations
wp_player_knifes - Knife customizations
wp_player_gloves - Glove customizations
wp_player_agents - Agent selections
wp_player_pins - Pin collections
# Health Monitoring Tables (added in 001_add_health_checks.sql)
health_check_history - Historical health check data
health_check_config - Health check configuration
# System Tables
_migrations - Migration trackingView migration files in server/database/migrations/ directory.
Testing
Run All Tests
npm testRun Tests in Watch Mode
npm run test:watchRun Tests with Coverage
npm run test:coverageTest Structure
tests/
├── unit/ # Component and utility tests
├── integration/ # API integration tests
└── e2e/ # End-to-end testsLinting and Code Quality
Run Linter
npm run lintAuto-fix Linting Issues
npm run lint -- --fixESLint Configuration
The project uses ESLint with:
- Nuxt recommended rules
- TypeScript support
- Vue 3 rules
- Tailwind CSS rules
Configuration: eslint.config.mjs
Development Workflow
1. Feature Branch Workflow
# Create feature branch
git checkout -b feature/my-new-feature
# Make changes
# ...
# Commit changes
git add .
git commit -m "Add new feature"
# Push to remote
git push origin feature/my-new-feature
# Create pull request on GitHub2. Component Development
When creating a new component:
- Create component file in
components/ - Use TypeScript for type safety
- Follow existing naming conventions
- Add to component documentation if major feature
- Write unit tests if applicable
Example:
<script setup lang="ts">
import { ref } from 'vue'
interface Props {
title: string
active?: boolean
}
const props = withDefaults(defineProps<Props>(), {
active: false
})
const emit = defineEmits<{
(e: 'click'): void
}>()
</script>
<template>
<div>
<!-- Component template -->
</div>
</template>3. API Development
When creating a new API endpoint:
- Create file in
server/api/ - Use TypeScript interfaces
- Implement authentication if needed
- Add error handling
- Document in API reference
- Write integration tests
Example:
// server/api/myendpoint.ts
import { defineEventHandler, readBody } from 'h3'
export default defineEventHandler(async (event) => {
try {
const body = await readBody(event)
// Your logic here
return {
success: true,
data: result
}
} catch (error) {
return {
success: false,
error: error.message
}
}
})Troubleshooting
Common Issues
1. Database Connection Errors
Error: ECONNREFUSED 127.0.0.1:3306
Solution:
# Check if MariaDB is running
sudo systemctl status mariadb
# Start MariaDB
sudo systemctl start mariadb
# Or with Docker
docker-compose up -d2. Steam Authentication Issues
Error: Steam API key invalid
Solution:
- Verify your Steam API key at https://steamcommunity.com/dev/apikey
- Ensure
STEAM_API_KEYin.envis correct - Check that your IP is not blocked by Steam
3. Port Already in Use
Error: Port 3000 is already in use
Solution:
# Find process using port 3000
lsof -i :3000
# Kill the process
kill -9 <PID>
# Or use a different port
PORT=3001 npm run dev4. Missing Dependencies
Error: Cannot find module 'xyz'
Solution:
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install5. TypeScript Errors
Error: Type 'X' is not assignable to type 'Y'
Solution:
# Regenerate type definitions
npm run postinstall
# Or restart TypeScript server in your IDE6. Steam Client Connection Issues
Error: Steam client disconnected or GC timeout
Solution:
- Check that
STEAM_USERNAMEandSTEAM_PASSWORDare correct - Ensure Steam Guard is disabled on the account (not currently supported)
- Wait a few minutes and retry (Steam may be rate limiting)
- Check Steam server status: https://steamstat.us/
7. Inspect URL Processing Fails
Error: Invalid inspect URL format
Solution:
- Verify the URL format (see API documentation)
- For unmasked URLs, ensure Steam account is configured
- Check that the item still exists (not deleted from inventory)
Development Tools
Useful Commands
# Generate static site
npm run generate
# Analyze bundle size
npm run build -- --analyze
# Update dependencies
npm update
# Check for outdated packages
npm outdated
# Clean build artifacts
rm -rf .nuxt .output node_modules/.cacheVS Code Settings
Create .vscode/settings.json:
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"files.associations": {
"*.css": "tailwindcss"
}
}Recommended VS Code Extensions
{
"recommendations": [
"Vue.volar",
"dbaeumer.vscode-eslint",
"bradlc.vscode-tailwindcss",
"Vue.vscode-typescript-vue-plugin"
]
}Next Steps
After setting up your development environment:
- Read the Architecture documentation
- Explore the Components guide
- Review the API Reference
- Check out How It Works
Production Deployment
For production environment variables and deployment configurations, see the Deployment Guide which includes complete environment variable references for all platforms.
Getting Help
- Documentation: Check other docs in the
docs/directory - Issues: Report bugs on GitHub Issues
- Discord: Join the community Discord (if available)
- Stack Overflow: Tag questions with
cs2inspect
Related Documentation
- Architecture - System architecture
- API Reference - API documentation
- How It Works - User flows
- Deployment - Production deployment and environment variables
- Contributing - Contribution guidelines