๐Ÿ“ฆ manideepk90 / hyperOTAServer

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching
๐Ÿ“ฅ Clone https://github.com/manideepk90/hyperOTAServer.git
HTTPS git clone https://github.com/manideepk90/hyperOTAServer.git
SSH git clone git@github.com:manideepk90/hyperOTAServer.git
CLI gh repo clone manideepk90/hyperOTAServer
Kuntimaddi Manideep Kuntimaddi Manideep feat: added ota version for local testing d9f1c45 7 months ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ ota
๐Ÿ“ uploads
๐Ÿ“„ .gitignore
๐Ÿ“„ config.json
๐Ÿ“„ ios-config.json
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ server.js
๐Ÿ“„ yarn.lock
๐Ÿ“„ README.md

HyperOTA Server

A Node.js server for serving Over-The-Air (OTA) updates and configurations for mobile applications.

Features

  • Serves configuration files for Android and iOS apps
  • Version-based configuration management
  • File upload and download capabilities
  • CORS enabled for cross-origin requests
  • Automatic network interface detection

Installation

npm install
# or
yarn install

Running the Server

node server.js

The server will start on port 3000 (or the port specified in the PORT environment variable) and display all available network interfaces.

API Endpoints

Configuration Endpoints

Android Configuration

  • GET /mobile-ota/android/:version/config.json
  • Returns configuration for the specified Android app version
  • Example: /mobile-ota/android/1.0.0/config.json

iOS Configuration

  • GET /mobile-ota/ios/:version/config.json
  • Returns configuration for the specified iOS app version
  • Example: /mobile-ota/ios/2.0.0/config.json

File Management Endpoints

List Files

  • GET /files - Lists all files in the Android uploads directory

Download Files

  • GET /files/android/:filename - Download a specific Android file
  • GET /files/ios/:filename - Download a specific iOS file
  • GET /files/locale/:localeName - Download a specific locale file

Version-Based Configuration System

The server supports serving different configurations based on the app version. It follows this priority order:

  • Version-specific config: ota/{version}/config.json
  • Default config: ota/default/config.json
  • Fallback config:
  • Android: config.json
  • iOS: ios-config2.json

Directory Structure

hyperOTAServer/
โ”œโ”€โ”€ server.js
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ config.json              # Fallback config for Android
โ”œโ”€โ”€ ios-config2.json         # Fallback config for iOS
โ”œโ”€โ”€ ota/                     # Version-based configs
โ”‚   โ”œโ”€โ”€ 1.0.0/
โ”‚   โ”‚   โ””โ”€โ”€ config.json
โ”‚   โ”œโ”€โ”€ 2.0.0/
โ”‚   โ”‚   โ””โ”€โ”€ config.json
โ”‚   โ””โ”€โ”€ default/
โ”‚       โ””โ”€โ”€ config.json
โ””โ”€โ”€ uploads/
    โ”œโ”€โ”€ android/
    โ”œโ”€โ”€ ios/
    โ””โ”€โ”€ locales/

Configuration Examples

Version-specific configuration

When a client requests /mobile-ota/ios/1.0.0/config.json, the server will:

  • First look for ota/1.0.0/config.json
  • If not found, check ota/default/config.json
  • If still not found, use ios-config2.json

Setting up configurations

  • Create version-specific folders in the ota directory:
mkdir -p ota/1.0.0
   mkdir -p ota/2.0.0
   mkdir -p ota/default

  • Place your config.json files in the appropriate folders
  • The server will automatically serve the correct configuration based on the requested version

Example Configuration File

{
  "version": "2",
  "config": {
    "version": "v2",
    "release_config_timeout": 2000,
    "boot_timeout": 2000,
    "properties": {}
  },
  "package": {
    "name": "Hyperswitch_SDK",
    "version": "v2",
    "properties": {
      "manifest": {},
      "manifest_hash": {}
    },
    "index": {
      "url": "http://localhost:3000/files/android/bundle-v1-android.zip",
      "filePath": "hyperswitch.bundle"
    },
    "important": [],
    "lazy": []
  },
  "resources": []
}

Logging

The server logs:

  • Startup information including all available network interfaces
  • Which configuration file is being served for each request
  • File access attempts and errors

CORS Configuration

The server is configured to accept requests from any origin (*). Modify the CORS settings in server.js if you need to restrict access to specific domains.

Environment Variables

  • PORT: Server port (default: 3000)

Error Handling

All endpoints include error handling and will return appropriate HTTP status codes:

  • 404: File or configuration not found
  • 500: Server error (e.g., failed to read configuration file)