Skip to content

AstrNest Configuration File

Configuration File Overview

AstrNest uses multiple configuration files to manage different aspects of the application:

  • Environment Variables File (.env): Basic application configuration
  • Backend Configuration File (application.yml): Backend service configuration
  • Frontend Configuration File (vite.config.js): Frontend build configuration

Environment Variables Configuration (.env)

Database Configuration

bash
# PostgreSQL Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=astrnest
DB_USER=astrnest_user
DB_PASSWORD=your_secure_password
DB_SSL=false

Redis Cache Configuration

REDIS_HOST=localhost REDIS_PORT=6379 REDIS_PASSWORD= REDIS_DB=0

Application Basic Configuration

APP_SECRET=your_jwt_secret_key APP_PORT=8080 NODE_ENV=production

File Upload Configuration

bash
# Upload Path Configuration
UPLOAD_PATH=./uploads
MAX_FILE_SIZE=20MB
ALLOWED_FILE_TYPES=image/jpeg,image/png,image/gif,image/webp

Image Processing Configuration

IMAGE_QUALITY=85 IMAGE_RESIZE_ENABLED=true MAX_IMAGE_WIDTH=3840 MAX_IMAGE_HEIGHT=2160


### Security Configuration

```bash
# CORS Configuration
CORS_ORIGIN=http://localhost:3000
CORS_CREDENTIALS=true

# Rate Limiting
RATE_LIMIT_WINDOW=900000
RATE_LIMIT_MAX=100

# JWT Configuration
JWT_EXPIRES_IN=7d
JWT_ISSUER=astrnest

Backend Configuration File (application.yml)

Server Configuration

yaml
server:
  port: 8080
  cors:
    allowed-origins: "http://localhost:3000"
    allowed-methods: "GET,POST,PUT,DELETE,OPTIONS"
    allowed-headers: "*"

spring:
  datasource:
    url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
    username: ${DB_USER}
    password: ${DB_PASSWORD}
    driver-class-name: org.postgresql.Driver

  redis:
    host: ${REDIS_HOST}
    port: ${REDIS_PORT}
    password: ${REDIS_PASSWORD}
    database: ${REDIS_DB}

File Upload Configuration

yaml
upload:
  path: ${UPLOAD_PATH}
  max-file-size: ${MAX_FILE_SIZE}
  allowed-types: ${ALLOWED_FILE_TYPES}
  
image:
  quality: ${IMAGE_QUALITY}
  resize-enabled: ${IMAGE_RESIZE_ENABLED}
  max-width: ${MAX_IMAGE_WIDTH}
  max-height: ${MAX_IMAGE_HEIGHT}

Frontend Configuration

Vite Configuration (vite.config.js)

javascript
export default defineConfig({
  server: {
    port: 3000,
    proxy: {
      '/api': {
        target: process.env.VITE_API_BASE_URL || 'http://localhost:8080',
        changeOrigin: true
      },
      '/upload': {
        target: process.env.VITE_UPLOAD_URL || 'http://localhost:8080',
        changeOrigin: true
      }
    }
  },
  
  build: {
    outDir: 'dist',
    assetsDir: 'assets',
    rollupOptions: {
      output: {
        manualChunks: {
          vendor: ['vue', 'vue-router', 'pinia'],
          ui: ['element-plus']
        }
      }
    }
  }
})

Environment Variables Configuration (.env)

bash
# API Configuration
VITE_API_BASE_URL=http://localhost:8080/api
VITE_UPLOAD_URL=http://localhost:8080/upload

# Application Configuration
VITE_APP_TITLE=AstrNest
VITE_MAX_FILE_SIZE=20
VITE_DEFAULT_LANGUAGE=en-US

# Feature Toggles
VITE_ENABLE_CDN=true
VITE_ENABLE_WATERMARK=false
VITE_ENABLE_COMPRESSION=true

Configuration Validation

Configuration Check Script

Create a configuration check script check-config.js:

javascript
const fs = require('fs');
const path = require('path');

// Check required environment variables
const requiredEnvVars = [
  'DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASSWORD',
  'APP_SECRET', 'UPLOAD_PATH'
];

const missingVars = requiredEnvVars.filter(varName => !process.env[varName]);

if (missingVars.length > 0) {
  console.error('❌ Missing required environment variables:', missingVars.join(', '));
  process.exit(1);
}

// Check if upload directory exists
const uploadPath = process.env.UPLOAD_PATH;
if (!fs.existsSync(uploadPath)) {
  console.log('📁 Creating upload directory:', uploadPath);
  fs.mkdirSync(uploadPath, { recursive: true });
}

console.log('✅ Configuration check passed');

Configuration Best Practices

Security Configuration

  1. Use Strong Passwords: Database passwords and JWT secrets should use strong random strings
  2. Enable HTTPS: Production environment must enable HTTPS
  3. Restrict File Types: Only allow safe image formats
  4. Set Reasonable File Size Limits: Prevent large file attacks

Performance Configuration

  1. Enable Redis Cache: Improve image access speed
  2. Configure CDN: Accelerate static resource access
  3. Enable Image Compression: Reduce bandwidth usage
  4. Set Reasonable Cache Policies: Optimize user experience