### Start Development Server Source: https://github.com/timvisee/send/blob/master/README.md Installs project dependencies and starts the Send application server in development configuration. After running these commands, the application will be accessible via a web browser. ```sh npm install npm start ``` -------------------------------- ### Install Node.js Dependencies for Send Source: https://github.com/timvisee/send/blob/master/docs/deployment.md Installs all Node.js package dependencies for the Send application. This command should be run as the web server user (e.g., www-data) to ensure correct permissions. ```bash npm install ``` -------------------------------- ### Install Send Dependencies on Debian/Ubuntu Source: https://github.com/timvisee/send/blob/master/docs/deployment.md This command installs necessary packages like Git, Apache, Node.js, npm, and telnet on Debian or Ubuntu systems required for deploying the Send application. ```bash sudo apt install git apache2 nodejs npm telnet ``` -------------------------------- ### Execute Send Background Script Source: https://github.com/timvisee/send/blob/master/docs/deployment.md Makes the `run.sh` script executable and then runs it to start the Send application as a background process. This initiates the Send backend on port 1443. ```bash chmod +x run.sh ./run.sh ``` -------------------------------- ### Build Send Application Source: https://github.com/timvisee/send/blob/master/docs/deployment.md Builds the Send application for production. This command should be run as the web server user after installing Node.js dependencies. ```bash npm run build ``` -------------------------------- ### Run Frontend Tests in Browser with npm Source: https://github.com/timvisee/send/blob/master/test/readme.md This command starts the development server, allowing frontend tests to be run directly in a web browser by navigating to `http://localhost:8080/test`. This method provides live reloading, automatically rerunning the test suite upon code changes. Unit tests are located in `test/frontend/tests`. ```bash npm start ``` -------------------------------- ### Docker Quickstart for Send Service Source: https://github.com/timvisee/send/blob/master/docs/docker.md Instructions to pull the latest Docker image for the 'send' service and run it with essential environment variables for file uploads and Redis integration. This setup mounts a local directory for uploads and exposes the service on port 1443. ```bash docker pull registry.gitlab.com/timvisee/send:latest # example quickstart (point REDIS_HOST to an already-running redis server) docker run -v $PWD/uploads:/uploads -p 1443:1443 \ -e 'DETECT_BASE_URL=true' \ -e 'REDIS_HOST=localhost' \ -e 'FILE_DIR=/uploads' \ registry.gitlab.com/timvisee/send:latest ``` -------------------------------- ### Run Integration Tests with npm and Docker Source: https://github.com/timvisee/send/blob/master/test/readme.md This command initiates integration tests, including UI tests powered by Selenium. It requires Docker to be installed and running for local execution. For debugging, a VNC connection can be established to `vnc://localhost:5900` with the password `secret` to observe the tests in real-time. Refer to `webdriver.io` documentation for advanced debugging. ```bash npm run test-integration ``` -------------------------------- ### Run Backend Tests with npm Source: https://github.com/timvisee/send/blob/master/test/readme.md This command executes the backend unit tests. The tests are located in the `test/backend` directory. Mocking frameworks like Sinon and proxyquire are utilized for isolating dependencies during testing. ```bash npm run test:backend ``` -------------------------------- ### Verify NodeJS and npm Installed Versions Source: https://github.com/timvisee/send/blob/master/docs/AWS.md These commands display the currently installed versions of Node.js and npm. This is useful for confirming that the correct versions are set up in the environment before proceeding with application deployment. ```bash node --version npm --version ``` -------------------------------- ### Install Core Application Packages on Ubuntu Source: https://github.com/timvisee/send/blob/master/docs/AWS.md This command updates the package list and installs the main application dependencies: Git for version control, NodeJS for the application runtime, Redis server for data storage, and Telnet for basic network diagnostics. ```bash sudo apt update sudo apt install git nodejs redis-server telnet ``` -------------------------------- ### Clone Send Repository Source: https://github.com/timvisee/send/blob/master/docs/deployment.md Clones the Send application repository into the specified htdocs directory. This step assumes the htdocs folder is empty or has been removed prior to cloning. ```bash git clone https://github.com/timvisee/send.git htdocs ``` -------------------------------- ### Test and Restart Apache Configuration Source: https://github.com/timvisee/send/blob/master/docs/deployment.md Tests the Apache configuration for syntax errors and then restarts the Apache web server to apply the new reverse proxy settings for the Send application. This ensures the changes take effect. ```bash sudo apache2ctl configtest sudo systemctl restart apache2 ``` -------------------------------- ### Install Core System Prerequisite Packages on Ubuntu Source: https://github.com/timvisee/send/blob/master/docs/AWS.md This command updates the package list and installs essential packages like `apt-transport-https`, `ca-certificates`, `curl`, and `software-properties-common` required for adding new software repositories securely on an Ubuntu system. ```bash sudo apt update sudo apt install -y apt-transport-https ca-certificates curl software-properties-common ``` -------------------------------- ### Run All Tests with npm Source: https://github.com/timvisee/send/blob/master/test/readme.md This command executes the entire test suite for the project, encompassing frontend, backend, and integration tests. It also generates a code coverage report, typically found at `coverage/index.html`. The full test suite is automatically run as a Git push hook, utilizing Mocha as the preferred test runner. ```bash npm test ``` -------------------------------- ### Enable Apache Proxy and Rewrite Modules Source: https://github.com/timvisee/send/blob/master/docs/deployment.md Enables essential Apache modules (headers, proxy, proxy_http, proxy_wstunnel, rewrite) required for configuring a reverse proxy for the Send application. These modules facilitate URL rewriting and proxying. ```bash sudo a2enmod headers sudo a2enmod proxy sudo a2enmod proxy_http sudo a2enmod proxy_wstunnel sudo a2enmod rewrite ``` -------------------------------- ### Run timvisee/send Backend with Docker Source: https://github.com/timvisee/send/blob/master/docs/docker.md This snippet demonstrates how to start the timvisee/send backend application using a `docker run` command. It configures network settings, mounts a volume for uploads, maps ports, and sets essential environment variables like `BASE_URL`, `MAX_FILE_SIZE`, `MAX_EXPIRE_SECONDS`, and `SEND_FOOTER_DMCA_URL` for the application's operation. ```bash docker run --net=timviseesend -v $PWD/uploads:/uploads -p 1443:1443 \ -e 'BASE_URL=http://localhost:1443' \ -e 'MAX_FILE_SIZE=5368709120' \ -e 'MAX_EXPIRE_SECONDS=2592000' \ -e 'SEND_FOOTER_DMCA_URL=https://example.com/dmca-contact-info' \ registry.gitlab.com/timvisee/send:latest ``` -------------------------------- ### Create Background Run Script for Send Source: https://github.com/timvisee/send/blob/master/docs/deployment.md Creates a shell script to run the Send application in the background as the www-data user, redirecting standard error to null. This ensures the application runs persistently. ```bash #!/bin/bash nohup su www-data -c "npm run prod" 2>/dev/null & ``` -------------------------------- ### Run Android Client Locally Source: https://github.com/timvisee/send/blob/master/README.md This command starts the local development server for the Android client, making it accessible via a web browser at http://localhost:8080 for easy testing and editing. It sets an environment variable to enable Android-specific features during the development process. ```Shell ANDROID=1 npm start ``` -------------------------------- ### Run Frontend Tests Headless with npm Source: https://github.com/timvisee/send/blob/master/test/readme.md This command executes frontend unit tests in a headless Chrome environment, printing the results directly to the console. This is useful for CI/CD pipelines or automated testing without a graphical interface. Unit tests are located in `test/frontend/tests`. ```bash npm run test:frontend ``` -------------------------------- ### Run Self-Hosted timvisee/send with Local Filesystem and Redis using Docker Source: https://github.com/timvisee/send/blob/master/docs/docker.md This example demonstrates setting up a self-hosted timvisee/send instance using Docker. It involves creating a Docker network, running a Redis container with persistent data on the local filesystem, and then running the timvisee/send application configured to use the local filesystem for uploads. ```bash # create a network for the send backend and redis containers to talk to each other docker network create timviseesend # start the redis container docker run --net=timviseesend -v $PWD/redis:/data redis-server --appendonly yes ``` -------------------------------- ### Deploy NodeJS Application from Git Repository Source: https://github.com/timvisee/send/blob/master/docs/AWS.md These commands facilitate the deployment: switching to the `www-data` user, navigating to the deployment directory, cloning the application repository, installing its Node.js dependencies, and building the application assets. The `exit` command returns to the previous user session. ```bash sudo su -l www-data -s /bin/bash cd /var/www/send git clone https://gitlab.com/timvisee/send.git . npm install npm run build exit ``` -------------------------------- ### Check Send Backend Status with Telnet Source: https://github.com/timvisee/send/blob/master/docs/deployment.md Verifies if the Send backend is running and listening on port 1443 by attempting a telnet connection to localhost. A successful connection indicates the service is active. ```bash telnet localhost 1443 ``` -------------------------------- ### Manage Redis Server Systemd Service Source: https://github.com/timvisee/send/blob/master/docs/AWS.md These commands enable the Redis server to start automatically on boot, restart the service immediately to apply any configuration changes, and check its current status to ensure the Redis server is running correctly. ```bash sudo systemctl enable redis-server sudo systemctl restart redis-server sudo systemctl status redis-server ``` -------------------------------- ### Manage Send Service with Systemctl Commands Source: https://github.com/timvisee/send/blob/master/docs/AWS.md These Bash commands are used to manage the 'Send' Systemd service. They reload the daemon configuration, enable the service for automatic startup on boot, start it immediately, check its current status, and view its logs for debugging and monitoring. ```Bash sudo systemctl daemon-reload sudo systemctl enable send sudo systemctl start send sudo systemctl status send journalctl -fu send ``` -------------------------------- ### Manage Docker Containers for Test Environment Source: https://github.com/timvisee/send/blob/master/test/integration/README.md These commands are used to check the status of Docker containers and start them in detached mode. This is necessary for the test environment, which includes Firefox Nightly and Selenium, allowing for live viewing of tests via VNC. ```sh docker-compose ps ``` ```sh docker-compose up -d ``` -------------------------------- ### Add Redis Labs PPA Repository to Ubuntu Source: https://github.com/timvisee/send/blob/master/docs/AWS.md This command adds the Redis Labs PPA to the system. This repository enables the installation of the latest stable Redis server packages, which is a required component for the 'Send' application's data storage. ```bash sudo add-apt-repository ppa:redislabs/redis ``` -------------------------------- ### Add NodeJS 15.x LTS Repository to Ubuntu Source: https://github.com/timvisee/send/blob/master/docs/AWS.md These commands add the GPG key for NodeSource and configure the APT repository for NodeJS 15.x LTS on an AMD64 Ubuntu system. This step is crucial for installing the specified NodeJS version, which is a dependency for the 'Send' application. ```bash curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add - echo 'deb [arch=amd64] https://deb.nodesource.com/node_15.x focal main' | sudo tee /etc/apt/sources.list.d/nodejs.list ``` -------------------------------- ### Translate strings using state.translate() in JavaScript Source: https://github.com/timvisee/send/blob/master/docs/localization.md Demonstrates how to use the `state.translate()` function to localize strings in JavaScript. It provides examples for translating simple strings and strings with parameters, leveraging dynamic data like filename and size. This function acts as a wrapper around FluentBundle.format and is compatible with both server-side and client-side rendering. ```js // simple string const finishedString = state.translate('downloadFinish') // with parameters const progressString = state.translate('downloadingPageProgress', { filename: state.fileInfo.name, size: bytes(state.fileInfo.size) }) ``` -------------------------------- ### Configure Apache Reverse Proxy for Send Source: https://github.com/timvisee/send/blob/master/docs/deployment.md Apache virtual host configuration to set up a reverse proxy for the Send application. It handles URL rewriting, preserves the host, ensures HTTPS forwarding, and proxies both HTTP and WebSocket connections to the Send backend running on port 1443. ```apacheconf # Enable rewrite engine RewriteEngine on # Make sure the original domain name is forwarded to Send # Otherwise the generated URLs will be wrong ProxyPreserveHost on # Make sure the generated URL is https:// RequestHeader set X-Forwarded-Proto https # If it's a normal file (e.g. PNG, CSS) just return it RewriteCond %{REQUEST_FILENAME} -f RewriteRule .* - [L] # If it's a websocket connection, redirect it to a Send WS connection RewriteCond %{HTTP:Upgrade} =websocket [NC] RewriteRule /(.*) ws://127.0.0.1:1443/$1 [P,L] # Otherwise redirect it to a normal HTTP connection RewriteRule ^/(.*)$ http://127.0.0.1:1443/$1 [P,QSA] ProxyPassReverse "/" "http://127.0.0.1:1443" ``` -------------------------------- ### Define Send Service with Systemd Unit File Source: https://github.com/timvisee/send/blob/master/docs/AWS.md This Systemd unit file defines the 'Send' service. It specifies the service type, execution command, environment variables, working directory, user/group, and restart policy. It also declares dependencies on network and Redis services, ensuring they are active before 'Send' starts. ```Systemd [Unit] Description=Send After=network.target Requires=redis-server.service Documentation=https://gitlab.com/timvisee/send [Service] Type=simple ExecStart=/usr/bin/npm run prod EnvironmentFile=/var/www/send/.env WorkingDirectory=/var/www/send User=www-data Group=www-data Restart=on-failure [Install] WantedBy=multi-user.target ``` -------------------------------- ### Configure IAM Policy for S3 Bucket Access Source: https://github.com/timvisee/send/blob/master/docs/AWS.md This JSON policy grants an EC2 instance permissions to list all S3 buckets, and to list, get, put, abort multipart uploads, and delete objects within a specific S3 bucket. It should be attached to the EC2 instance's IAM role for application access to S3. ```json { "Version": "2012-10-17", "Statement": [ { "Action": [ "s3:ListAllMyBuckets" ], "Resource": [ "*" ], "Effect": "Allow" }, { "Action": [ "s3:ListBucket", "s3:GetBucketLocation", "s3:ListBucketMultipartUploads" ], "Resource": [ "arn:aws:s3:::" ], "Effect": "Allow" }, { "Action": [ "s3:GetObject", "s3:GetObjectVersion", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:AbortMultipartUpload", "s3:DeleteObject", "s3:DeleteObjectVersion" ], "Resource": [ "arn:aws:s3:::/*" ], "Effect": "Allow" } ] } ``` -------------------------------- ### Send Project Build Commands and Configuration Details Source: https://github.com/timvisee/send/blob/master/docs/build.md This section outlines the primary npm commands used to build and serve the Send project, distinguishing between development and production environments. It details the functionality of each command, the tools involved (Webpack, Express), and the notable differences in how assets are handled, security features (CSP), testing, and sourcemaps are applied across environments. ```Shell npm start - Purpose: Launches the development environment. - Action: Starts a `webpack-dev-server` on port 8080. - Compilation: Compiles assets in memory; no `dist/` directory is generated. - Features: Watches files for changes, serves backend API and frontend unit tests via `server/bin/dev.js`. - Testing: Frontend tests are accessible in the browser at `http://localhost:8080/test` and rerun automatically on file changes. - Security: Does not enable CSP headers. - Coverage: Frontend source is instrumented for code coverage. - Debugging: Includes sourcemaps. - Routes: Exposes the `/test` route. npm run build - Purpose: Compiles assets for the production environment. - Action: Compiles all project assets. - Output: Writes the compiled files to the `dist/` directory. npm run prod - Purpose: Launches the production server. - Action: Starts an Express server on port 1443. - Serving: Serves the backend API and frontend static assets from the `dist/` directory. - Entrypoint: Uses `server/bin/prod.js` as the server entrypoint. - Caching: Sets Cache-Control immutable headers on hashed static assets. ``` -------------------------------- ### Run Integration Tests for Send Source: https://github.com/timvisee/send/blob/master/test/integration/README.md This snippet shows the commands to build the project and then execute the integration tests using npm scripts. The tests are managed by Tox and run with Pytest. ```sh npm run build npm run test-integration ``` -------------------------------- ### Project Development Commands Source: https://github.com/timvisee/send/blob/master/README.md A comprehensive list of `npm` commands available for developing, testing, and building the Send application. These commands facilitate code formatting, linting, testing, and managing server configurations. ```APIDOC npm run format: Formats the frontend and server code using prettier. npm run lint: Lints the CSS and JavaScript code. npm test: Runs the suite of mocha tests. npm start: Runs the server in development configuration. npm run build: Builds the production assets. npm run prod: Runs the server in production configuration. ``` -------------------------------- ### Build Send Service Docker Image Locally Source: https://github.com/timvisee/send/blob/master/docs/docker.md Command to build a Docker image for the 'send' service from a local repository clone. This allows for custom image creation and local development. ```bash docker build -t send:latest . ``` -------------------------------- ### Add Git Core PPA Repository to Ubuntu Source: https://github.com/timvisee/send/blob/master/docs/AWS.md This command adds the official Git Core PPA (Personal Package Archive) to the system. This repository provides access to the latest stable versions of Git, ensuring the deployment environment has an up-to-date version for cloning the application. ```bash sudo add-apt-repository ppa:git-core/ppa ``` -------------------------------- ### Configure Storage and Redis Backend for timvisee/send Source: https://github.com/timvisee/send/blob/master/docs/docker.md This section details the environment variables used to configure the storage backend (local filesystem, S3, Google Cloud Storage) and the Redis metadata database for the timvisee/send application. It specifies parameters for connection details and bucket names. ```APIDOC Storage Backend and Redis Configuration: REDIS_HOST, REDIS_PORT, REDIS_USER, REDIS_PASSWORD, REDIS_DB - Description: Host name, port, user, and password for the Redis server. - Default: localhost (host), 6379 (port), no password. - Type: string (host, user, password), integer (port, db) FILE_DIR - Description: Directory for local file storage inside the Docker container. - Default: /uploads - Type: string (path) S3_BUCKET - Description: The S3 bucket name to use for storage. Required if using S3. - Type: string S3_ENDPOINT - Description: Optional custom endpoint for S3. Defaults to AWS. - Type: string (URL) S3_USE_PATH_STYLE_ENDPOINT - Description: Forces path style URLs for S3 objects. - Default: false - Type: boolean AWS_ACCESS_KEY_ID - Description: S3 access key ID. Required if using S3. - Type: string AWS_SECRET_ACCESS_KEY - Description: S3 secret access key. Required if using S3. - Type: string GCS_BUCKET - Description: Google Cloud Storage bucket name. Required if using GCP. - Type: string ``` -------------------------------- ### Run timvisee/send Backend with Custom Branding Source: https://github.com/timvisee/send/blob/master/docs/docker.md This snippet shows how to run the timvisee/send backend with custom branding applied to its user interface. It utilizes Docker's volume mounting to inject custom assets and sets environment variables such as `UI_COLOR_PRIMARY`, `UI_COLOR_ACCENT`, and `UI_CUSTOM_ASSETS_ICON` to modify the UI's appearance. ```bash docker run -p 1443:1443 \ -v $PWD/custom_assets:/app/dist/custom_assets \ -e 'UI_COLOR_PRIMARY=#f00' \ -e 'UI_COLOR_ACCENT=#a00' \ -e 'UI_CUSTOM_ASSETS_ICON=custom_assets/logo.svg' \ registry.gitlab.com/timvisee/send:latest ``` -------------------------------- ### Create and Secure Website Deployment Directory Source: https://github.com/timvisee/send/blob/master/docs/AWS.md These commands create the `/var/www/send` directory, set its ownership to the `www-data` user and group (commonly used for web servers), and apply restrictive permissions (750) to ensure only the owner and group can access it, enhancing security. ```bash sudo mkdir -pv /var/www/send sudo chown www-data:www-data /var/www/send sudo 750 /var/www/send ``` -------------------------------- ### Configure UI Branding and Custom Assets for timvisee/send Source: https://github.com/timvisee/send/blob/master/docs/docker.md This section lists environment variables for customizing the user interface of the timvisee/send application, including primary and accent colors, and paths for various custom assets like icons, favicons, social media images, and custom CSS/footer text. ```APIDOC UI Branding and Custom Assets Configuration: UI_COLOR_PRIMARY - Description: The primary color for the UI. - Default: #0a84ff - Type: string (hex color code) UI_COLOR_ACCENT - Description: The accent color for the UI (e.g., for hover-effects). - Default: #003eaa - Type: string (hex color code) UI_CUSTOM_ASSETS_ANDROID_CHROME_192PX - Description: Path to a custom icon for Android (192x192px). - Type: string (path/URL) UI_CUSTOM_ASSETS_ANDROID_CHROME_512PX - Description: Path to a custom icon for Android (512x512px). - Type: string (path/URL) UI_CUSTOM_ASSETS_APPLE_TOUCH_ICON - Description: Path to a custom icon for Apple devices. - Type: string (path/URL) UI_CUSTOM_ASSETS_FAVICON_16PX - Description: Path to a custom favicon (16x16px). - Type: string (path/URL) UI_CUSTOM_ASSETS_FAVICON_32PX - Description: Path to a custom favicon (32x32px). - Type: string (path/URL) UI_CUSTOM_ASSETS_ICON - Description: Path to a custom icon (Logo on the top-left of the UI). - Type: string (path/URL) UI_CUSTOM_ASSETS_SAFARI_PINNED_TAB - Description: Path to a custom icon for Safari pinned tabs. - Type: string (path/URL) UI_CUSTOM_ASSETS_FACEBOOK - Description: Path to a custom header image for Facebook. - Type: string (path/URL) UI_CUSTOM_ASSETS_TWITTER - Description: Path to a custom header image for Twitter. - Type: string (path/URL) UI_CUSTOM_ASSETS_WORDMARK - Description: Path to a custom wordmark (Text next to the logo). - Type: string (path/URL) UI_CUSTOM_CSS - Description: Path to a custom CSS file for custom styling. - Type: string (path/URL) CUSTOM_FOOTER_TEXT - Description: Custom text to display in the footer. - Type: string CUSTOM_FOOTER_URL - Description: Custom URL to link the footer text to. - Type: string (URL) ``` -------------------------------- ### Send Service Server Configuration Environment Variables Source: https://github.com/timvisee/send/blob/master/docs/docker.md Environment variables for configuring the core server behavior of the 'send' service, including base URL detection, listening port, and error tracking. These settings define how the server operates and interacts with its environment. ```APIDOC BASE_URL: The HTTPS URL where traffic will be served (e.g. https://send.firefox.com) DETECT_BASE_URL: Autodetect the base URL using browser if BASE_URL is unset (defaults to false) PORT: Port the server will listen on (defaults to 1443) NODE_ENV: Run in development mode (unsafe) or production mode (the default) SEND_FOOTER_DMCA_URL: A URL to a contact page for DMCA requests (empty / not shown by default) SENTRY_CLIENT: Sentry Client ID for error tracking (optional, disabled by default) SENTRY_DSN: Sentry DSN for error tracking (optional, disabled by default) ``` -------------------------------- ### Adjust Application File and Directory Permissions Source: https://github.com/timvisee/send/blob/master/docs/AWS.md These commands recursively set appropriate permissions for the deployed application: 750 for directories and 640 for files, ensuring `www-data` ownership and restricting access. A special command is included to set executable permissions (750) for binaries within `node_modules/.bin`. ```bash sudo find /var/www/send -type d -exec chmod 750 {} \; sudo find /var/www/send -type f -exec chmod 640 {} \; sudo find -L /var/www/send/node_modules/.bin/ -exec chmod 750 {} \; ``` -------------------------------- ### Run timvisee/send with S3, Redis Elasticache, and Sentry using Docker Source: https://github.com/timvisee/send/blob/master/docs/docker.md This Docker command demonstrates how to run the timvisee/send application configured to use Amazon S3 for file storage, Amazon Elasticache for Redis, and Sentry for error reporting. Environment variables are set to specify bucket names, Redis host, and Sentry DSNs. ```bash docker run -p 1443:1443 \ -e 'S3_BUCKET=testpilot-p2p-dev' \ -e 'REDIS_HOST=dyf9s2r4vo3.bolxr4.0001.usw2.cache.amazonaws.com' \ -e 'SENTRY_CLIENT=https://51e23d7263e348a7a3b90a5357c61cb2@sentry.prod.mozaws.net/168' \ -e 'SENTRY_DSN=https://51e23d7263e348a7a3b90a5357c61cb2:65e23d7263e348a7a3b90a5357c61c44@sentry.prod.mozaws.net/168' \ -e 'BASE_URL=https://send.example.com' \ registry.gitlab.com/timvisee/send:latest ``` -------------------------------- ### Send Service Upload and Download Limit Configuration Source: https://github.com/timvisee/send/blob/master/docs/docker.md Environment variables to configure file size limits, archive limits, expiration times, and download counts for the 'send' service. These settings are crucial for managing resource usage and preventing abuse on public instances, allowing administrators to define acceptable usage policies. ```APIDOC MAX_FILE_SIZE: Maximum upload file size in bytes (defaults to 2147483648 aka 2GB) MAX_FILES_PER_ARCHIVE: Maximum number of files per archive (defaults to 64) MAX_EXPIRE_SECONDS: Maximum upload expiry time in seconds (defaults to 604800 aka 7 days) MAX_DOWNLOADS: Maximum number of downloads (defaults to 100) DOWNLOAD_COUNTS: Download limit options to show in UI dropdown, e.g. 10,1,2,5,10,15,25,50,100,1000 EXPIRE_TIMES_SECONDS: Expire time options to show in UI dropdown, e.g. 3600,86400,604800,2592000,31536000 DEFAULT_DOWNLOADS: Default download limit in UI (defaults to 1) DEFAULT_EXPIRE_SECONDS: Default expire time in UI (defaults to 86400) ``` -------------------------------- ### Configure Application Environment Variables Source: https://github.com/timvisee/send/blob/master/docs/AWS.md This block illustrates the structure of the `.env` file, which defines critical environment variables for the NodeJS application. These variables include the base URL, Node.js environment mode, application port, Redis password, and S3 bucket name, essential for application runtime. ```bash BASE_URL='https://send.mydomain.com' NODE_ENV='production' PORT='8080' REDIS_PASSWORD='' S3_BUCKET='' ``` -------------------------------- ### Client-Side Test Report Table Interactions Source: https://github.com/timvisee/send/blob/master/test/integration/send-test.html This JavaScript code provides a comprehensive set of functions for enhancing an HTML table displaying test results. It includes functionalities for sorting columns (alphabetically, numerically, or by test result status), filtering rows based on test outcomes, and collapsing/expanding detailed sections within the report. The `init` function serves as the main entry point, setting up event listeners for interactive elements. Note that helper functions like `find` and `find_all` are assumed to be defined elsewhere, and the initial part of the `add_collapse` function is truncated in the provided snippet. ```JavaScript var expandcollapse = document.createElement("span"); if (collapsed.includes(elem.innerHTML)) { extras.classList.add("collapsed"); expandcollapse.classList.add("expander"); } else { expandcollapse.classList.add("collapser"); } elem.appendChild(expandcollapse); elem.addEventListener("click", function(event) { if (event.currentTarget.parentNode.nextElementSibling.classList.contains("collapsed")) { show_extras(event.currentTarget); } else { hide_extras(event.currentTarget); } }); }) } function get_query_parameter(name) { var match = RegExp('\\[?&\\]' + name + '=(\\[^&\\]*)').exec(window.location.search); return match && decodeURIComponent(match[1].replace(/\\+/g, ' ')); } function init () { reset_sort_headers(); add_collapse(); show_filters(); toggle_sort_states(find('.initial-sort')); find_all('.sortable').forEach(function(elem) { elem.addEventListener("click", function(event) { sort_column(elem); }, false) }); }; function sort_table(clicked, key_func) { var rows = find_all('.results-table-row'); var reversed = !clicked.classList.contains('asc'); var sorted_rows = sort(rows, key_func, reversed); /* Whole table is removed here because browsers acts much slower * when appending existing elements. */ var thead = document.getElementById("results-table-head"); document.getElementById('results-table').remove(); var parent = document.createElement("table"); parent.id = "results-table"; parent.appendChild(thead); sorted_rows.forEach(function(elem) { parent.appendChild(elem); }); document.getElementsByTagName("BODY")[0].appendChild(parent); } function sort(items, key_func, reversed) { var sort_array = items.map(function(item, i) { return [key_func(item), i]; }); var multiplier = reversed ? -1 : 1; sort_array.sort(function(a, b) { var key_a = a[0]; var key_b = b[0]; return multiplier * (key_a >= key_b ? 1 : -1); }); return sort_array.map(function(item) { var index = item[1]; return items[index]; }); } function key_alpha(col_index) { return function(elem) { return elem.childNodes[1].childNodes[col_index].firstChild.data.toLowerCase(); }; } function key_num(col_index) { return function(elem) { return parseFloat(elem.childNodes[1].childNodes[col_index].firstChild.data); }; } function key_result(col_index) { return function(elem) { var strings = ['Error', 'Failed', 'Rerun', 'XFailed', 'XPassed', 'Skipped', 'Passed']; return strings.indexOf(elem.childNodes[1].childNodes[col_index].firstChild.data); }; } function reset_sort_headers() { find_all('.sort-icon').forEach(function(elem) { elem.parentNode.removeChild(elem); }); find_all('.sortable').forEach(function(elem) { var icon = document.createElement("div"); icon.className = "sort-icon"; icon.textContent = "vvv"; elem.insertBefore(icon, elem.firstChild); elem.classList.remove("desc", "active"); elem.classList.add("asc", "inactive"); }); } function toggle_sort_states(elem) { //if active, toggle between asc and desc if (elem.classList.contains('active')) { elem.classList.toggle('asc'); elem.classList.toggle('desc'); } //if inactive, reset all other functions and add ascending active if (elem.classList.contains('inactive')) { reset_sort_headers(); elem.classList.remove('inactive'); elem.classList.add('active'); } } function is_all_rows_hidden(value) { return value.hidden == false; } function filter_table(elem) { var outcome_att = "data-test-result"; var outcome = elem.getAttribute(outcome_att); class_outcome = outcome + " results-table-row"; var outcome_rows = document.getElementsByClassName(class_outcome); for(var i = 0; i < outcome_rows.length; i++){ outcome_rows[i].hidden = !elem.checked; } var rows = find_all('.results-table-row').filter(is_all_rows_hidden); var all_rows_hidden = rows.length == 0 ? true : false; var not_found_message = document.getElementById("not-found-message"); not_found_message.hidden = !all_rows_hidden; } ``` -------------------------------- ### Define A/B Experiment Logic in JavaScript Source: https://github.com/timvisee/send/blob/master/docs/experiments.md This JavaScript code defines a comprehensive experiment object for a specific Google Analytics Experiment ID. It includes `run` to apply changes based on the chosen variant, `eligible` to determine if the experiment should activate for the current session (e.g., based on user agent or language), and `variant` to randomly assign a user to an experimental group. It also shows a helper `luckyNumber` function. ```javascript const experiments = { S9wqVl2SQ4ab2yZtqDI3Dw: { // The Experiment ID from Google Analytics id: 'S9wqVl2SQ4ab2yZtqDI3Dw', run: function(variant, state, emitter) { switch (variant) { case 1: state.promo = 'blue'; break; case 2: state.promo = 'pink'; break; default: state.promo = 'grey'; } emitter.emit('render'); }, eligible: function() { return ( !/firefox|fxios/i.test(navigator.userAgent) && document.querySelector('html').lang === 'en-US' ); }, variant: function(state) { const n = this.luckyNumber(state); if (n < 0.33) { return 0; } return n < 0.66 ? 1 : 2; }, luckyNumber: function(state) { return luckyNumber( `${this.id}:${state.storage.get('testpilot_ga__cid')}` ); } } }; ``` -------------------------------- ### Generate Strong Password for Redis Source: https://github.com/timvisee/send/blob/master/docs/AWS.md This command uses `makepasswd` to generate a strong, 100-character random password. This generated password should be used to secure the Redis server by configuring it in the `redis.conf` file. ```bash makepasswd --chars=100 ``` -------------------------------- ### Redis Key Management Commands Source: https://github.com/timvisee/send/blob/master/docs/takedowns.md Documentation for Redis commands relevant to managing and deleting keys, specifically the `DEL` command used in the 'Send' service's file take-down process. These commands interact directly with the Redis database to manage stored data. ```APIDOC DEL key [key ...] - Deletes one or more keys from Redis. - Parameters: - key: The name of the key to delete. Can specify multiple keys. - Returns: Integer reply: The number of keys that were removed. - Time complexity: O(N) where N is the number of keys that will be removed. When a key to delete contains a large number of items (e.g., a List, Set, or Hash with many elements), this operation can be slow. - Usage Context: Used in the 'Send' service to remove file records from the Redis database during a take-down process, typically via `redis-cli DEL `. ``` -------------------------------- ### Update Global npm Package Manager Source: https://github.com/timvisee/send/blob/master/docs/AWS.md This command updates the Node Package Manager (npm) to its latest version globally. Keeping npm updated ensures access to the newest features, performance improvements, and bug fixes for managing Node.js project dependencies. ```bash sudo npm install -g npm ``` -------------------------------- ### CSS for Test Report Layout and Theming Source: https://github.com/timvisee/send/blob/master/test/integration/send-test.html Defines the visual styles for a test report, including general body styles, heading styles, table layouts, and specific color schemes for test results (passed, skipped, error). It also includes styles for log displays, images, and interactive elements like detail expanders and sorting icons. ```CSS body { font-family: Helvetica, Arial, sans-serif; font-size: 12px; min-width: 1200px; color: #999; } h1 { font-size: 24px; color: black; } h2 { font-size: 16px; color: black; } p { color: black; } a { color: #999; } table { border-collapse: collapse; } /* SUMMARY INFORMATION */ #environment td { padding: 5px; border: 1px solid #E6E6E6; } #environment tr:nth-child(odd) { background-color: #f6f6f6; } /* TEST RESULT COLORS */ span.passed, .passed .col-result { color: green; } span.skipped, span.xfailed, span.rerun, .skipped .col-result, .xfailed .col-result, .rerun .col-result { color: orange; } span.error, span.failed, span.xpassed, .error .col-result, .failed .col-result, .xpassed .col-result { color: red; } /* RESULTS TABLE * 1. Table Layout * 2. Extra * 3. Sorting items */ /*------------------ * 1. Table Layout *------------------*/ #results-table { border: 1px solid #e6e6e6; color: #999; font-size: 12px; width: 100% } #results-table th, #results-table td { padding: 5px; border: 1px solid #E6E6E6; text-align: left } #results-table th { font-weight: bold } /*------------------ * 2. Extra *------------------*/ .log:only-child { height: inherit } .log { background-color: #e6e6e6; border: 1px solid #e6e6e6; color: black; display: block; font-family: "Courier New", Courier, monospace; height: 230px; overflow-y: scroll; padding: 5px; white-space: pre-wrap } div.image { border: 1px solid #e6e6e6; float: right; height: 240px; margin-left: 5px; overflow: hidden; width: 320px } div.image img { width: 320px } .collapsed { display: none; } .expander::after { content: " (show details)"; color: #BBB; font-style: italic; cursor: pointer; } .collapser::after { content: " (hide details)"; color: #BBB; font-style: italic; cursor: pointer; } /*------------------ * 3. Sorting items *------------------*/ .sortable { cursor: pointer; } .sort-icon { font-size: 0px; float: left; margin-right: 5px; margin-top: 5px; /*triangle*/ width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; } .inactive .sort-icon { /*finish triangle*/ border-top: 8px solid #E6E6E6; } .asc.active .sort-icon { /*finish triangle*/ border-bottom: 8px solid #999; } .desc.active .sort-icon { /*finish triangle*/ border-top: 8px solid #999; } ``` -------------------------------- ### JavaScript Functions for Test Report Interactivity Source: https://github.com/timvisee/send/blob/master/test/integration/send-test.html Provides a collection of JavaScript functions to enhance the interactivity of a test report. This includes utilities for DOM manipulation (converting iterables to arrays, finding elements), functions for sorting table columns, and mechanisms to show/hide detailed information for test results, both individually and globally. It also includes a function to show filters and add collapse/expand links, though the latter is truncated. ```JavaScript function toArray(iter) { if (iter === null) { return null; } return Array.prototype.slice.call(iter); } function find(selector, elem) { if (!elem) { elem = document; } return elem.querySelector(selector); } function find_all(selector, elem) { if (!elem) { elem = document; } return toArray(elem.querySelectorAll(selector)); } function sort_column(elem) { toggle_sort_states(elem); var colIndex = toArray(elem.parentNode.childNodes).indexOf(elem); var key; if (elem.classList.contains('numeric')) { key = key_num; } else if (elem.classList.contains('result')) { key = key_result; } else { key = key_alpha; } sort_table(elem, key(colIndex)); } function show_all_extras() { find_all('.col-result').forEach(show_extras); } function hide_all_extras() { find_all('.col-result').forEach(hide_extras); } function show_extras(colresult_elem) { var extras = colresult_elem.parentNode.nextElementSibling; var expandcollapse = colresult_elem.firstElementChild; extras.classList.remove("collapsed"); expandcollapse.classList.remove("expander"); expandcollapse.classList.add("collapser"); } function hide_extras(colresult_elem) { var extras = colresult_elem.parentNode.nextElementSibling; var expandcollapse = colresult_elem.firstElementChild; extras.classList.add("collapsed"); expandcollapse.classList.remove("collapser"); expandcollapse.classList.add("expander"); } function show_filters() { var filter_items = document.getElementsByClassName('filter'); for (var i = 0; i < filter_items.length; i++) filter_items[i].hidden = false; } function add_collapse() { // Add links for show/hide all var resulttable = find('table#results-table'); var showhideall = document.createElement("p"); showhideall.innerHTML = 'Show all details / ' + 'Hide all details'; resulttable.parentElement.insertBefore(showhideall, resulttable); // Add show/hide link to each result find_all('.col-result').forEach(function(elem) { var collapsed = get_query_parameter('collapsed') || 'Passed'; var extras = elem.parentNode.nextElementSibl ``` -------------------------------- ### Emit Custom Event for Experiment Goal Reporting Source: https://github.com/timvisee/send/blob/master/docs/experiments.md This JavaScript snippet demonstrates how to use an `emit` function to trigger a custom 'experiment' event. This event is crucial for reporting specific actions as the goal for an A/B experiment in Google Analytics, often including custom dimensions for filtering. ```javascript emit('experiment', { cd3: 'promo' }); ``` -------------------------------- ### Delist File Record from Redis using redis-cli Source: https://github.com/timvisee/send/blob/master/docs/takedowns.md This shell command demonstrates how to remove a file's record from the Redis database, effectively delisting it from the 'Send' service. It is typically used as part of a take-down process for DMCA or abuse cases. The command requires the file's unique ID. ```sh redis-cli DEL 3d9d2bb9a1 ``` -------------------------------- ### Define expiration constant in JavaScript Source: https://github.com/timvisee/send/blob/master/ios/send-ios/assets/index.html This snippet defines a constant `EXPIRE_SECONDS` with a value of 86400. This value represents the number of seconds in a single day (24 hours * 60 minutes * 60 seconds) and is commonly used for setting default expiration periods for data, tokens, or sessions within an application. ```JavaScript const EXPIRE_SECONDS = 86400; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.