### Auto-Detect Platform Download - Bash Source: https://context7.com/vercel/hazel/llms.txt This code demonstrates how to download an application installer by automatically detecting the user's operating system via the User-Agent header. It shows examples for macOS and Windows, including how to handle the `update=true` parameter for macOS to download a .zip file instead of a .dmg. The expected response on success is a 302 redirect to the GitHub asset URL, and on failure, a 404 error. ```bash # Download from macOS (User-Agent indicates Mac) curl -L https://your-hazel-server.vercel.app/download \ -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)" \ -o app-installer # Download from Windows (User-Agent indicates Windows) curl -L https://your-hazel-server.vercel.app/download \ -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)" \ -o app-installer.exe # Response on success: 302 redirect to GitHub asset URL # Response on failure: 404 "No download available for your platform!" # Download with update parameter (uses .zip instead of .dmg on macOS) curl -L "https://your-hazel-server.vercel.app/download?update=true" \ -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)" ``` -------------------------------- ### GET /download/:platform - Platform-Specific Download Source: https://context7.com/vercel/hazel/llms.txt Accepts a platform identifier and redirects to the corresponding release asset. Supports platform aliases for easier integration. ```APIDOC ## GET /download/:platform ### Description Accepts a platform identifier (darwin, win32, exe, dmg, deb, rpm, AppImage, or their ARM64 variants) and redirects to the corresponding release asset. Supports platform aliases like 'mac', 'windows', 'osx' for easier integration. ### Method GET ### Endpoint /download/:platform ### Path Parameters - **platform** (string) - Required - The platform identifier (e.g., `darwin`, `win32`, `dmg`, `exe`, `deb`, `rpm`, `AppImage`, `darwin_arm64`, `dmg_arm64`). Aliases like `mac`, `windows`, `osx` are also supported. ### Request Example ```bash # Download macOS version curl -L https://your-hazel-server.vercel.app/download/darwin # Download Windows version using alias curl -L https://your-hazel-server.vercel.app/download/win32 # Download specific file formats curl -L https://your-hazel-server.vercel.app/download/dmg # macOS DMG curl -L https://your-hazel-server.vercel.app/download/exe # Windows EXE curl -L https://your-hazel-server.vercel.app/download/deb # Debian package curl -L https://your-hazel-server.vercel.app/download/rpm # Fedora package curl -L https://your-hazel-server.vercel.app/download/AppImage # Linux AppImage # Download ARM64 versions curl -L https://your-hazel-server.vercel.app/download/darwin_arm64 curl -L https://your-hazel-server.vercel.app/download/dmg_arm64 ``` ### Response Example #### Success Response (302) Redirects to the GitHub asset download URL. #### Error Response (404) "No download available for your platform" #### Error Response (500) "The specified platform is not valid" ``` -------------------------------- ### GET / - Overview Page Source: https://context7.com/vercel/hazel/llms.txt Displays a web interface showing the cached repository information including available platforms, file sizes, version numbers, and direct download links. This endpoint renders an HTML page. ```APIDOC ## GET / ### Description Displays a web interface showing the cached repository information including available platforms, file sizes, version numbers, and direct download links. This endpoint renders an HTML page using Handlebars templates with details about the current release. ### Method GET ### Endpoint / ### Request Example ```bash # Request the overview page curl https://your-hazel-server.vercel.app/ ``` ### Response Example ```html # Response: HTML page showing # - Repository name and GitHub link # - Current version and release date # - Available platform downloads (macOS, Windows, Linux) # - File sizes for each platform # - Links to release notes and all releases ``` ``` -------------------------------- ### GET /download - Auto-Detect Platform Download Source: https://context7.com/vercel/hazel/llms.txt Automatically detects the visitor's operating system by parsing the user agent header and redirects to the appropriate platform-specific download. Returns 404 if no suitable platform is detected. ```APIDOC ## GET /download ### Description Automatically detects the visitor's operating system by parsing the user agent header and redirects to the appropriate platform-specific download. Returns 404 if no suitable platform is detected or if the release doesn't contain assets for that platform. ### Method GET ### Endpoint /download ### Query Parameters - **update** (boolean) - Optional - If true, uses `.zip` instead of `.dmg` on macOS. ### Request Example ```bash # Download from macOS (User-Agent indicates Mac) curl -L https://your-hazel-server.vercel.app/download \ -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)" \ -o app-installer # Download from Windows (User-Agent indicates Windows) curl -L https://your-hazel-server.vercel.app/download \ -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)" \ -o app-installer.exe # Download with update parameter (uses .zip instead of .dmg on macOS) curl -L "https://your-hazel-server.vercel.app/download?update=true" \ -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)" ``` ### Response Example #### Success Response (302) Redirects to the GitHub asset URL. #### Error Response (404) "No download available for your platform!" ``` -------------------------------- ### GET /update/win32/:version/RELEASES Source: https://context7.com/vercel/hazel/llms.txt Retrieves the RELEASES file required by Squirrel.Windows for update checks. It contains metadata for available .nupkg files with direct URLs to GitHub assets. Returns 204 if the file is not found in the cache. ```APIDOC ## GET /update/win32/:version/RELEASES ### Description Returns the RELEASES file required by Squirrel.Windows for checking updates. This file contains metadata about available .nupkg files with full URLs to GitHub assets. Returns 204 if the file is not available in the cached release. ### Method GET ### Endpoint `/update/win32/:version/RELEASES` ### Parameters #### Path Parameters - **version** (string) - Required - The version of the release. ### Request Example ```bash curl https://your-hazel-server.vercel.app/update/win32/1.0.0/RELEASES ``` ### Response #### Success Response (200) - **body** (binary) - The RELEASES file content with updated URLs. #### Response Example ``` # Body contains modified RELEASES content with full URLs: A1B2C3D4E5F6G7H8 https://github.com/account/repo/releases/download/1.1.0/app-1.1.0-full.nupkg 12345678 ``` #### No Content Response (204) - **body** (empty) - Returned when the RELEASES file is not available in the cache. ``` -------------------------------- ### GET /update/:platform/:version - Check for Updates Source: https://context7.com/vercel/hazel/llms.txt Checks if an update is available for a given platform and version number. Returns update information if available, or 204 No Content if no update is needed. ```APIDOC ## GET /update/:platform/:version ### Description Checks if an update is available for a given platform and version number. Returns update information including release notes and download URL if the versions differ (even if downgrading). Returns 204 No Content if the versions match or if no release is available. ### Method GET ### Endpoint /update/:platform/:version ### Path Parameters - **platform** (string) - Required - The platform identifier (e.g., `darwin`, `win32`). - **version** (string) - Required - The current version of the application (e.g., `1.0.0`). Must be SemVer-compatible. ### Request Example ```bash # Check for updates on macOS curl https://your-hazel-server.vercel.app/update/darwin/1.0.0 # Check for updates on Windows curl https://your-hazel-server.vercel.app/update/win32/2.0.0 # Invalid version format curl https://your-hazel-server.vercel.app/update/darwin/invalid ``` ### Response Example #### Success Response (200) - **name** (string) - The new version number. - **notes** (string) - Release notes for the new version. - **pub_date** (string) - The publication date of the release in ISO 8601 format. - **url** (string) - The download URL for the new version. ```json { "name": "1.1.0", "notes": "## What's New\n\n- Fixed critical bug\n- Added new feature", "pub_date": "2025-10-08T12:00:00Z", "url": "https://github.com/account/repo/releases/download/1.1.0/app-darwin.zip" } ``` #### Success Response (204) No update available or versions match. Empty body. #### Error Response (500) - **error** (string) - Error code (e.g., `version_invalid`). - **message** (string) - Description of the error. ```json { "error": "version_invalid", "message": "The specified version is not SemVer-compatible" } ``` ``` -------------------------------- ### Check for Updates - Bash and JSON Source: https://context7.com/vercel/hazel/llms.txt This example shows how to check for application updates using the `/update/:platform/:version` endpoint. It includes `curl` commands for checking updates on macOS and Windows, along with the expected JSON response when an update is available (HTTP 200) and the behavior when no update is available (HTTP 204). It also demonstrates the error response for an invalid version format (HTTP 500). ```bash # Check for updates on macOS curl https://your-hazel-server.vercel.app/update/darwin/1.0.0 # Response when update available (HTTP 200): { "name": "1.1.0", "notes": "## What's New\n\n- Fixed critical bug\n- Added new feature", "pub_date": "2025-10-08T12:00:00Z", "url": "https://github.com/account/repo/releases/download/1.1.0/app-darwin.zip" } # Response when no update available: HTTP 204 (empty body) # Check for updates on Windows curl https://your-hazel-server.vercel.app/update/win32/2.0.0 # Invalid version format curl https://your-hazel-server.vercel.app/update/darwin/invalid # Response: HTTP 500 { "error": "version_invalid", "message": "The specified version is not SemVer-compatible" } ``` -------------------------------- ### Integrate Electron Auto-Updater with Hazel Source: https://context7.com/vercel/hazel/llms.txt This JavaScript snippet demonstrates how to set up Electron's auto-updater to work with a Hazel server for application updates. It configures the update feed URL based on the platform and application version and includes logic to only check for updates in production builds. The code also handles update events like availability, download completion, and errors, prompting the user to restart for installation. ```javascript // In your Electron main process const { app, autoUpdater } = require('electron') // Configure update server const server = 'https://your-hazel-server.vercel.app' const platform = process.platform const version = app.getVersion() const updateURL = `${server}/update/${platform}/${version}` // Only check for updates in production if (!app.isPackaged) { console.log('Skipping updates in development') } else { // Set the update feed URL autoUpdater.setFeedURL({ url: updateURL }) // Check for updates when app starts autoUpdater.checkForUpdates() // Check for updates every 10 minutes setInterval(() => { autoUpdater.checkForUpdates() }, 10 * 60 * 1000) // Handle update events autoUpdater.on('update-available', () => { console.log('Update available, downloading...') }) autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { console.log('Update downloaded:', releaseName) // Show notification to user dialog.showMessageBox({ type: 'info', title: 'Update Ready', message: 'A new version has been downloaded. Restart to apply updates.', buttons: ['Restart', 'Later'] }).then((returnValue) => { if (returnValue.response === 0) { autoUpdater.quitAndInstall() } }) }) autoUpdater.on('error', (err) => { console.error('Update error:', err) }) } ``` -------------------------------- ### Initialize and Configure Hazel Server Source: https://context7.com/vercel/hazel/llms.txt Demonstrates how to create and configure a Hazel server instance. The server handles routing and caching, initializes the Cache class, and binds all routes. The returned request handler can be used with Node.js HTTP servers or serverless platforms like Vercel. Includes basic configuration options and error handling for missing properties. ```javascript const hazel = require('hazel-server') // Basic configuration const server = hazel({ account: 'vercel', // GitHub account/org name repository: 'hyper', // GitHub repository name interval: 15, // Cache refresh interval in minutes (default: 15) pre: false, // Set to true to serve pre-releases only token: '', // GitHub token for private repos url: 'https://example.com' // Server URL (required for private repos) }) // Use with http.createServer const http = require('http') http.createServer(server).listen(3000) // Use with micro (Vercel serverless) const micro = require('micro') micro(server).listen(3000) // Configuration error handling try { const invalidServer = hazel({ /* missing account/repository */ }) } catch (err) { console.error(err.code) // 'missing_configuration_properties' console.error(err.message) // 'Neither ACCOUNT, nor REPOSITORY are defined' } ``` -------------------------------- ### Request Overview Page - Bash Source: https://context7.com/vercel/hazel/llms.txt This snippet shows how to request the overview page of the Hazel server using curl. The response is an HTML page detailing the current release information, including available platforms, file sizes, version numbers, and download links. ```bash # Request the overview page curl https://your-hazel-server.vercel.app/ # Response: HTML page showing # - Repository name and GitHub link # - Current version and release date # - Available platform downloads (macOS, Windows, Linux) # - File sizes for each platform # - Links to release notes and all releases ``` -------------------------------- ### Configure Hazel Server with Environment Variables Source: https://context7.com/vercel/hazel/llms.txt Hazel utilizes environment variables for configuration on serverless platforms like Vercel. Key variables include `ACCOUNT` and `REPOSITORY` for specifying the GitHub source. Optional variables allow customization of cache refresh intervals (`INTERVAL`), pre-release serving (`PRE`), and authentication for private repositories (`TOKEN`, `URL`). VERCEL_URL is automatically detected if `URL` is not explicitly set. ```bash # Required environment variables ACCOUNT=vercel # GitHub account or organization name REPOSITORY=hyper # GitHub repository name # Optional environment variables INTERVAL=15 # Cache refresh interval in minutes (default: 15) PRE=1 # Serve pre-releases instead of stable releases TOKEN=ghp_token123 # GitHub personal access token for private repos URL=https://server.com # Server URL (required when TOKEN is set) # Vercel automatic variables VERCEL_URL # Automatically set by Vercel, used if URL is not set # Start the server with environment variables ACCOUNT=vercel REPOSITORY=hyper node server.js ``` -------------------------------- ### hazel(config) Source: https://context7.com/vercel/hazel/llms.txt The main entry point for creating and configuring a Hazel server instance. It sets up routing, caching, and returns a request handler function compatible with Node.js HTTP servers and serverless platforms. ```APIDOC ## hazel(config) ### Description Creates and configures a Hazel server instance with routing and caching. Initializes the Cache class and binds all routes. Returns a request handler function that can be used with any Node.js HTTP server or serverless platform. ### Method Function Call ### Parameters #### Request Body - **config** (object) - Required - Configuration object for the Hazel server. - **account** (string) - Required - GitHub account or organization name. - **repository** (string) - Required - GitHub repository name. - **interval** (number) - Optional - Cache refresh interval in minutes (default: 15). - **pre** (boolean) - Optional - Set to true to serve pre-releases only. - **token** (string) - Optional - GitHub token for private repositories. - **url** (string) - Required if token is set - Server URL. ### Request Example ```javascript const hazel = require('hazel-server') const server = hazel({ account: 'vercel', repository: 'hyper', interval: 15, pre: false, token: '', url: 'https://example.com' }) const http = require('http') http.createServer(server).listen(3000) ``` ### Response #### Success Response - **requestHandler** (function) - A function that can be used as an HTTP server request handler. ``` -------------------------------- ### Platform-Specific Download - Bash Source: https://context7.com/vercel/hazel/llms.txt This snippet illustrates how to download application assets for specific platforms using the `/download/:platform` endpoint. It covers various platform identifiers and aliases, including ARM64 variants. The expected responses are a 302 redirect on success, a 404 error for unavailable platforms, and a 500 error for invalid platform specifications. ```bash # Download macOS version curl -L https://your-hazel-server.vercel.app/download/darwin # Download Windows version using alias curl -L https://your-hazel-server.vercel.app/download/win32 # Download specific file formats curl -L https://your-hazel-server.vercel.app/download/dmg # macOS DMG curl -L https://your-hazel-server.vercel.app/download/exe # Windows EXE curl -L https://your-hazel-server.vercel.app/download/deb # Debian package curl -L https://your-hazel-server.vercel.app/download/rpm # Fedora package curl -L https://your-hazel-server.vercel.app/download/AppImage # Linux AppImage # Download ARM64 versions curl -L https://your-hazel-server.vercel.app/download/darwin_arm64 curl -L https://your-hazel-server.vercel.app/download/dmg_arm64 # Response on success: 302 redirect to GitHub asset download URL # Response on failure: 404 "No download available for your platform" # Response on invalid platform: 500 "The specified platform is not valid" ``` -------------------------------- ### Fetch Windows RELEASES File for Updates Source: https://context7.com/vercel/hazel/llms.txt Retrieves the RELEASES file necessary for Squirrel.Windows to check for application updates. This file contains metadata about available .nupkg files, including direct URLs to GitHub assets. A 204 status code is returned if the file is not found in the cache. ```bash # Fetch RELEASES file for Windows update curl https://your-hazel-server.vercel.app/update/win32/1.0.0/RELEASES # Response: HTTP 200 with content-type: application/octet-stream # Body contains modified RELEASES content with full URLs: # A1B2C3D4E5F6G7H8 https://github.com/account/repo/releases/download/1.1.0/app-1.1.0-full.nupkg 12345678 # Response when not available: HTTP 204 (empty body) ``` -------------------------------- ### Electron Manual Update Check and Download Logic (JavaScript) Source: https://context7.com/vercel/hazel/llms.txt This snippet provides functions for manually checking for updates and downloading them within an Electron application. It uses `node-fetch` for HTTP requests and `fs` for file system operations. It sends progress and status updates to the renderer process via IPC. ```javascript const { app, BrowserWindow, ipcMain, dialog } = require('electron') const fetch = require('node-fetch') const fs = require('fs') const path = require('path') const server = 'https://your-hazel-server.vercel.app' // Manual update check function async function checkForUpdates(window) { try { const platform = process.platform const version = app.getVersion() const updateURL = `${server}/update/${platform}/${version}` const response = await fetch(updateURL) if (response.status === 204) { // No update available window.webContents.send('update-status', { available: false, message: 'You are running the latest version' }) return null } if (response.status === 200) { const update = await response.json() window.webContents.send('update-status', { available: true, version: update.name, notes: update.notes, url: update.url, publishedAt: update.pub_date }) return update } throw new Error(`Update check failed: ${response.status}`) } catch (err) { console.error('Update check error:', err) window.webContents.send('update-error', err.message) return null } } // Download update manually async function downloadUpdate(downloadURL, window) { try { const response = await fetch(downloadURL) const filename = path.basename(downloadURL) const downloadPath = path.join(app.getPath('downloads'), filename) const fileStream = fs.createWriteStream(downloadPath) const totalSize = parseInt(response.headers.get('content-length'), 10) let downloaded = 0 response.body.on('data', (chunk) => { downloaded += chunk.length const progress = (downloaded / totalSize) * 100 window.webContents.send('download-progress', progress) }) await new Promise((resolve, reject) => { response.body.pipe(fileStream) response.body.on('error', reject) fileStream.on('finish', resolve) }) window.webContents.send('download-complete', downloadPath) return downloadPath } catch (err) { console.error('Download error:', err) window.webContents.send('download-error', err.message) throw err } } // IPC handlers for renderer processipcMain.handle('check-updates', async (event) => { const window = BrowserWindow.fromWebContents(event.sender) return await checkForUpdates(window) }) ipcMain.handle('download-update', async (event, url) => { const window = BrowserWindow.fromWebContents(event.sender) return await downloadUpdate(url, window) }) ``` -------------------------------- ### Manage GitHub Release Data with Cache Class Source: https://context7.com/vercel/hazel/llms.txt Provides functionality for managing GitHub release data caching. The Cache class automatically refreshes data at specified intervals, fetches releases from the GitHub API, processes assets by platform, and offers methods to check cache freshness and load cached data. It includes handling for missing configuration properties and demonstrates the structure of the loaded release data. ```javascript const Cache = require('hazel-server/lib/cache') // Initialize cache const cache = new Cache({ account: 'vercel', repository: 'hyper', interval: 15, // Optional: minutes between refreshes pre: false, // Optional: serve pre-releases token: 'ghp_token123', // Optional: for private repos url: 'https://server.com' // Required if token is set }) // Load cached data (auto-refreshes if outdated) const releaseData = await cache.loadCache() console.log(releaseData) // { // version: '1.1.0', // notes: 'Release notes markdown', // pub_date: '2025-10-08T12:00:00Z', // platforms: { // darwin: { // name: 'app-darwin.zip', // url: 'https://github.com/.../app-darwin.zip', // api_url: 'https://api.github.com/repos/.../assets/123', // content_type: 'application/zip', // size: 45.2 // MB // }, // exe: { /* ... */ }, // dmg: { /* ... */ } // }, // files: { // RELEASES: 'A1B2C3... https://... 12345678' // } // } // Manual cache refresh await cache.refreshCache() // Check if cache is outdated const needsRefresh = cache.isOutdated() // true if older than interval // Handle missing configuration try { const invalidCache = new Cache({}) } catch (err) { console.error(err.code) // 'missing_configuration_properties' console.error(err.message) // 'Neither ACCOUNT, nor REPOSITORY are defined' } ``` -------------------------------- ### checkPlatform(fileName) Source: https://context7.com/vercel/hazel/llms.txt Analyzes a release asset filename to determine the corresponding platform identifier. It supports common Electron build outputs and ARM64 architecture detection. ```APIDOC ## checkPlatform(fileName) ### Description Analyzes a release asset filename and returns the corresponding platform identifier. Supports standard Electron build outputs and ARM64 architecture detection. ### Method Function Call ### Parameters #### Path Parameters - **fileName** (string) - Required - The name of the release asset file. ### Request Example ```javascript const checkPlatform = require('hazel-server/lib/platform') checkPlatform('MyApp-darwin.zip') checkPlatform('MyApp-Setup-arm64.exe') ``` ### Response #### Success Response - **platformIdentifier** (string | boolean) - The detected platform identifier (e.g., 'darwin', 'exe', 'dmg_arm64') or `false` if the platform cannot be determined. ``` -------------------------------- ### Cache Class Source: https://context7.com/vercel/hazel/llms.txt Manages the caching of GitHub release data with automatic refresh capabilities. It fetches releases, processes assets by platform, and provides methods for checking cache status and loading data. ```APIDOC ## Cache Class ### Description Manages GitHub release data caching with automatic refresh intervals. Fetches releases from GitHub API, processes assets by platform, and provides methods to check cache freshness and load cached data. ### Method Class Instantiation and Methods ### Constructor Parameters #### Request Body - **config** (object) - Required - Configuration object for the Cache. - **account** (string) - Required - GitHub account or organization name. - **repository** (string) - Required - GitHub repository name. - **interval** (number) - Optional - Cache refresh interval in minutes (default: 15). - **pre** (boolean) - Optional - Set to true to serve pre-releases only. - **token** (string) - Optional - GitHub token for private repositories. - **url** (string) - Required if token is set - Server URL. ### Methods #### loadCache() - **Description**: Loads cached release data. Refreshes the cache automatically if it's outdated. - **Returns**: (Promise) - A promise that resolves with the release data. #### refreshCache() - **Description**: Manually refreshes the cache by fetching the latest release data from GitHub. - **Returns**: (Promise) #### isOutdated() - **Description**: Checks if the cache is older than the configured interval. - **Returns**: (boolean) - `true` if the cache is outdated, `false` otherwise. ### Request Example ```javascript const Cache = require('hazel-server/lib/cache') const cache = new Cache({ account: 'vercel', repository: 'hyper', interval: 15, pre: false, token: 'ghp_token123', url: 'https://server.com' }) const releaseData = await cache.loadCache() console.log(releaseData) await cache.refreshCache() const needsRefresh = cache.isOutdated() ``` ### Response Example (for loadCache) ```json { "version": "1.1.0", "notes": "Release notes markdown", "pub_date": "2025-10-08T12:00:00Z", "platforms": { "darwin": { "name": "app-darwin.zip", "url": "https://github.com/.../app-darwin.zip", "api_url": "https://api.github.com/repos/.../assets/123", "content_type": "application/zip", "size": 45.2 }, "exe": { /* ... */ }, "dmg": { /* ... */ } }, "files": { "RELEASES": "A1B2C3... https://... 12345678" } } ``` ``` -------------------------------- ### Detect Platform from Filename Source: https://context7.com/vercel/hazel/llms.txt Analyzes release asset filenames to determine the corresponding platform identifier. This utility function supports common Electron build output formats and includes detection for ARM64 architecture. It returns the platform string or `false` for unrecognized filenames. ```javascript const checkPlatform = require('hazel-server/lib/platform') // macOS detection checkPlatform('MyApp-darwin.zip') // 'darwin' checkPlatform('MyApp-mac.zip') // 'darwin' checkPlatform('MyApp-darwin-arm64.zip') // 'darwin_arm64' checkPlatform('MyApp.dmg') // 'dmg' checkPlatform('MyApp-arm64.dmg') // 'dmg_arm64' // Windows detection checkPlatform('MyApp-Setup.exe') // 'exe' checkPlatform('MyApp-Setup-arm64.exe') // 'exe_arm64' // Linux detection checkPlatform('MyApp.deb') // 'deb' checkPlatform('MyApp.rpm') // 'rpm' checkPlatform('MyApp.AppImage') // 'AppImage' checkPlatform('MyApp-arm64.AppImage') // 'AppImage_arm64' // Unknown files checkPlatform('README.md') // false checkPlatform('source.tar.gz') // false ``` -------------------------------- ### Integrate Hazel into HTTP Server (JavaScript) Source: https://github.com/vercel/hazel/blob/master/README.md This snippet demonstrates how to integrate the Hazel server into an existing Node.js HTTP server. It requires the 'hazel-server' package. The hazel function handles incoming requests and responses, allowing for custom analytics on specific paths. ```javascript const hazel = require('hazel-server') http.createServer((req, res) => { hazel(req, res) }) ``` -------------------------------- ### Resolve Platform Aliases with Hazel Source: https://context7.com/vercel/hazel/llms.txt The `checkAlias` function converts user-friendly platform names (e.g., 'mac', 'windows') into canonical internal identifiers used by Hazel. It supports various aliases for macOS, Windows, and Linux, including ARM64 variants. Aliases that do not map to a known platform return `false`. ```javascript const checkAlias = require('hazel-server/lib/aliases') // macOS aliases checkAlias('darwin') // 'darwin' checkAlias('mac') // 'darwin' checkAlias('macos') // 'darwin' checkAlias('osx') // 'darwin' checkAlias('mac_arm64') // 'darwin_arm64' // Windows aliases checkAlias('exe') // 'exe' checkAlias('win32') // 'exe' checkAlias('windows') // 'exe' checkAlias('win') // 'exe' // Linux aliases checkAlias('deb') // 'deb' checkAlias('debian') // 'deb' checkAlias('rpm') // 'rpm' checkAlias('fedora') // 'rpm' checkAlias('AppImage') // 'AppImage' checkAlias('appimage') // 'AppImage' // DMG format checkAlias('dmg') // 'dmg' // ARM64 variants checkAlias('darwin_arm64') // 'darwin_arm64' checkAlias('macos_arm64') // 'darwin_arm64' // Unknown aliases checkAlias('unknown') // false checkAlias('linux') // false ``` -------------------------------- ### Electron Auto Updater Configuration Source: https://github.com/vercel/hazel/blob/master/README.md This JavaScript snippet demonstrates how to configure Electron's autoUpdater to use a Hazel deployment as its update feed URL. It constructs the URL based on the server address, operating system platform, and application version. ```javascript const { app, autoUpdater } = require('electron') const server = const url = `${server}/update/${process.platform}/${app.getVersion()}` autoUpdater.setFeedURL({ url }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.