### Kutt.it Setup and Development Commands Source: https://github.com/thedevs-network/kutt/blob/main/README.md These commands are used for setting up and running the Kutt.it application. They cover dependency installation, database migration, and starting the development server or production build. ```shell npm install npm run migrate npm run dev npm start ``` -------------------------------- ### Example Docker Copy Command Source: https://github.com/thedevs-network/kutt/blob/main/README.md A concrete example demonstrating how to use the `docker cp` command to transfer a local 'custom' directory into a Kutt container named 'kutt-server-1'. ```sh docker cp custom kutt-server-1:/kutt ``` -------------------------------- ### Kutt.it Docker Compose Commands Source: https://github.com/thedevs-network/kutt/blob/main/README.md These commands demonstrate how to use Docker Compose to deploy and manage Kutt.it instances. Different configurations are available for various database and caching setups, including default SQLite, SQLite with Redis, PostgreSQL with Redis, and MariaDB with Redis. ```shell docker compose up docker compose -f up ``` -------------------------------- ### Docker Command to Copy Custom Folder Source: https://github.com/thedevs-network/kutt/blob/main/README.md Provides the Docker command-line instruction to copy a local custom folder into a running Kutt container. This is essential for applying local customizations to a Dockerized Kutt instance. ```sh docker cp :/kutt ``` -------------------------------- ### Kutt Helm Chart Source: https://github.com/thedevs-network/kutt/blob/main/README.md A Helm chart for deploying Kutt on a Kubernetes cluster. This configuration defines the necessary resources and settings for running Kutt in a Kubernetes environment. ```Kubernetes/Helm # This is a conceptual representation of a Helm chart's values.yaml or deployment.yaml # Actual chart structure would include templates, Chart.yaml, etc. # Example values.yaml snippet for Kutt deployment: replicaCount: 1 image: repository: kutt1/kutt pullPolicy: IfNotPresent tag: "latest" service: type: ClusterIP port: 80 ingress: enabled: true className: "nginx" annotations: {} hosts: - host: "kutt.yourdomain.com" paths: - path: "/" pathType: ImplementationSpecific resources: {} nodeSelector: {} tolerations: [] affinity: {} # Configuration for Kutt itself (e.g., database, API key) config: databaseUrl: "postgres://user:password@host:port/database" baseUrl: "https://kutt.yourdomain.com" apiKey: "YOUR_SECURE_API_KEY" ``` -------------------------------- ### Kutt Custom Folder Structure Source: https://github.com/thedevs-network/kutt/blob/main/README.md Illustrates the directory layout for custom assets within the Kutt application. This structure allows for organized placement of CSS, images, and view templates. ```tree custom/ ├─ css/ │ ├─ custom1.css │ ├─ custom2.css │ ├─ ... ├─ images/ │ ├─ logo.png │ ├─ favicon.ico │ ├─ ... ├─ views/ │ ├─ partials/ │ │ ├─ footer.hbs │ ├─ 404.hbs │ ├─ ... ``` -------------------------------- ### ShareX Kutt URL Shortener Configuration (JSON) Source: https://github.com/thedevs-network/kutt/wiki/ShareX This JSON configuration allows ShareX to use a Kutt instance as its default URL shortener. It specifies the request URL, headers (including the API key and target URL), and the URL format for the shortened link. Users need to replace 'yourapikeyhere' with their actual Kutt API key and ensure the RequestURL points to their Kutt instance. ```JSON { "Name": "kutt", "DestinationType": "URLShortener", "RequestURL": "https://kutt.it/api/url/sharex", "Headers": { "X-API-Key": "yourapikeyhere", "Target": "{\"target\":\"$input$\"}" }, "URL": "$json:shortUrl$" } ``` -------------------------------- ### Kutt Application Configuration Variables Source: https://github.com/thedevs-network/kutt/blob/main/README.md Environment variables used to configure the Kutt URL shortener. These variables control various aspects of the application, including security, database connections, caching, email services, and UI customization. Variables can also be set using `_FILE` suffix to read values from files. ```APIDOC General Configuration: JWT_SECRET Description: Used to sign authentication tokens. Must be a long, random string. Required: Yes (on production) Example: "a_very_long_and_secure_random_string" PORT Description: The port the application listens on. Default: "3000" Example: "8888" SITE_NAME Description: The name of the website displayed in the UI. Default: "Kutt" Example: "Your Site" DEFAULT_DOMAIN Description: The primary domain address the app runs on. Default: "localhost:3000" Example: "yoursite.com" LINK_LENGTH Description: The length of the shortened URL slugs. Default: "6" Example: "5" LINK_CUSTOM_ALPHABET Description: Custom alphabet for generating shortened addresses. Default omits confusing characters (o, O, 0, i, I, l, 1, j). Default: "(abcd..789)" Example: "abcABC^&*()@" DISALLOW_REGISTRATION Description: Disables user registration. If MAIL_ENABLED is false, registration is also disabled. Default: "true" Example: "false" DISALLOW_ANONYMOUS_LINKS Description: Disables the creation of links by unauthenticated users. Default: "true" Example: "false" TRUST_PROXY Description: Enables trusting proxy headers to get the correct client IP address. Set to false if not behind a proxy. Default: "true" Example: "false" SERVER_IP_ADDRESS Description: Displayed IP address on the settings page (for informational purposes only). Example: "1.2.3.4" SERVER_CNAME_ADDRESS Description: Displayed CNAME address on the settings page (for informational purposes only). Example: "custom.yoursite.com" CUSTOM_DOMAIN_USE_HTTPS Description: Enables HTTPS for custom domain links. Requires manual SSL certificate generation. Default: "false" Example: "true" ENABLE_RATE_LIMIT Description: Enables rate limiting for API routes. Uses Redis if available, otherwise memory. Default: "false" Example: "true" MAIL_ENABLED Description: Enables email functionalities (signup, verification, password reset, reports). If disabled, these features are unavailable. Default: "false" Example: "true" REPORT_EMAIL Description: The email address that receives submitted reports. Example: "example@yoursite.com" CONTACT_EMAIL Description: The support email address displayed in the app. Example: "example@yoursite.com" ``` ```APIDOC Database Configuration: DB_CLIENT Description: Specifies the database client to use. Supported: 'pg', 'pg-native', 'mysql2', 'sqlite3', 'better-sqlite3'. Note: 'pg-native' and 'sqlite3' require separate npm installation. Default: "better-sqlite3" Example: "pg" DB_FILENAME Description: File path for the SQLite database. Used only when DB_CLIENT is 'sqlite3' or 'better-sqlite3'. Default: "db/data" Example: "/var/lib/data" DB_HOST Description: Database connection host. Used for PostgreSQL or MySQL. Default: "localhost" Example: "your-db-host.com" DB_PORT Description: Database connection port. Used for PostgreSQL or MySQL. Default: "5432" (Postgres) / "3306" (MySQL) Example: "3306" DB_NAME Description: Database name. Used for PostgreSQL or MySQL. Default: "kutt" Example: "mydb" DB_USER Description: Database user. Used for PostgreSQL or MySQL. Default: "postgres" Example: "myuser" DB_PASSWORD Description: Database password. Used for PostgreSQL or MySQL. Example: "mypassword" DB_SSL Description: Enables SSL for the database connection. Used for PostgreSQL or MySQL. Default: "false" Example: "true" DB_POOL_MIN Description: Minimum number of database connection pools. Used for PostgreSQL or MySQL. Default: "0" Example: "2" DB_POOL_MAX Description: Maximum number of database connection pools. Used for PostgreSQL or MySQL. Default: "10" Example: "5" ``` ```APIDOC Redis Configuration: REDIS_ENABLED Description: Enables Redis for caching. Default: "false" Example: "true" REDIS_HOST Description: Redis server connection host. Default: "127.0.0.1" Example: "your-redis-host.com" REDIS_PORT Description: Redis server port. Default: "6379" Example: "6379" REDIS_PASSWORD Description: Redis server password. Example: "mypassword" REDIS_DB Description: Redis database number (0-15). Default: "0" Example: "1" ``` ```APIDOC Email Configuration: MAIL_HOST Description: Email server host. Example: "your-mail-server.com" MAIL_PORT Description: Email server port. Default: "587" Example: "465" (for SSL) MAIL_USER Description: Email server username. Example: "myuser" MAIL_PASSWORD Description: Email server password for the user. Example: "mypassword" MAIL_FROM Description: Email address from which emails are sent. Example: "example@yoursite.com" MAIL_SECURE Description: Enables SSL for the email server connection. Default: "false" Example: "true" ``` -------------------------------- ### Kutt API BASH Function Source: https://github.com/thedevs-network/kutt/blob/main/README.md A simple BASH function designed to interact with the Kutt API for URL shortening. It demonstrates basic API call structure using curl. ```BASH function kutt_shorten() { local url="$1" local api_key="YOUR_API_KEY" local api_url="https://kutt.it/api/v1/links" if [ -z "$url" ]; then echo "Usage: kutt_shorten " return 1 fi curl -s -X POST -H "Content-Type: application/json" -H "X-API-Key: $api_key" -d "{\"target\": \"$url\"}" "$api_url" | jq -r '.link' } # Example usage: # kutt_shorten "https://www.google.com" ``` -------------------------------- ### NGINX Server Configuration for Kutt Source: https://github.com/thedevs-network/kutt/wiki/NGINX-config This NGINX configuration handles HTTP to HTTPS redirection, sets up SSL/TLS with recommended ciphers and protocols, and proxies requests to a backend application running on localhost:8888. It includes security headers, caching directives, and specific proxy rules for API endpoints. ```nginx proxy_cache_path /home/pouria/.nginxcache levels=1:2 keys_zone=my_cache:10m max_size=10g \ inactive=60m use_temp_path=off; # Advanced config for NGINX server_tokens off; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options nosniff; # Redirect all HTTP traffic to HTTPS server { if ($host = kutt.it) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name www.kutt.it kutt.it; return 301 https://$host$request_uri; } # SSL configuration server { listen 443 ssl default deferred; server_name www.kutt.it kutt.it; ssl_certificate /etc/letsencrypt/live/kutt.it/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/kutt.it/privkey.pem; # managed by Certbot # Improve HTTPS performance with session resumption ssl_session_cache shared:SSL:10m; ssl_session_timeout 5m; # Enable server-side protection against BEAST attacks ssl_prefer_server_ciphers on; ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5; # Disable SSLv3 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Enable HSTS (https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security) add_header Strict-Transport-Security "max-age=63072000; includeSubdomains"; # Enable OCSP stapling (http://blog.mozilla.org/security/2013/07/29/ocsp-stapling-in-firefox) ssl_stapling on; ssl_stapling_verify on; ssl_trusted_certificate /etc/letsencrypt/live/kutt.it/fullchain.pem; resolver 8.8.8.8 8.8.4.4 valid=300s; resolver_timeout 5s; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; location / { proxy_cache my_cache; proxy_cache_revalidate on; proxy_cache_min_uses 3; proxy_cache_background_update on; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; proxy_cache_lock on; proxy_pass http://localhost:8888; proxy_http_version 1.1; } location /api/url/sharex { proxy_pass http://localhost:8888/api/url/submit; proxy_redirect off; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Content-Type application/json; proxy_set_body $http_target; } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.