Skip to content

IRON-M4N/MegaCDN

Repository files navigation

$\textcolor{red}{Mega}\textcolor{white}{CDN}$

A lightweight and serverless CDN utilizing MEGA for file storage and delivery.


Features

  • Stores in mega.nz cloud
  • Multi-account load balancing
  • PostgreSQL, MongoDB, SQLite support
  • Auto-delete & auth token
  • Rate limit & size check
  • Shortened filenames

DEPLOY TO HEROKU

  1. If you don’t have an account on Heroku, create one.

    Create Heroku

  2. Now deploy:

    Deploy Heroku

DEPLOY TO VERCEL

  1. If you don’t have an account on Vercel, create one.

    Create Vercel

  2. Now deploy:

    Deploy Vercel

DEPLOY TO RAILWAY

  1. If you don’t have an account on Railway, create one.

    Create Railway

  2. Now deploy:

    Deploy Railway

DEPLOY TO RENDER

  1. If you don’t have an account on Render, create one.

    Create Render

  2. Now deploy:

    Deploy Render

DEPLOY TO KOYEB

  1. If you don’t have an account on Koyeb, create one.

    Create Koyeb

  2. Now deploy:

    Deploy Koyeb

DEPLOY TO REPLIT

  1. If you don’t have an account on Replit, create one.

    Create Replit

  2. Now deploy:

    Deploy Replit

Installation

git clone https://github.com/IRON-M4N/MegaCDN.git
cd MegaCDN
npm install
cp .env.example .env
npm run build
npm start

API Endpoints

Method Endpoint Description
POST /upload Upload files
GET /file/:name Serve file by custom CDN URL
GET /media/:name Original MEGA URL
GET /info Server info
GET /health Health check

Example:

curl -X POST -F "[email protected]" http://cdn.yourdomain.com/upload

Upload Modes

# Single mode (default)
curl -X POST -F "[email protected]" http://cdn.yourdomain.com/upload

# Dual mode (specify MEGA email)
curl -X POST -F "[email protected]" -F "mode=dual" -F "[email protected]" http://cdn.yourdomain.com/upload

# With Auth
curl -H "Authorization: Bearer YOUR_TOKEN" ...

Example Response

{
  "success": true,
  "files": [
    {
      "url": "https://cdn.yourdomaincom/media/abcDEF123.png",
      "name": "skirk.png",
      "size": 1523200,
      "formattedSize": "1.45 MB",
      "mime": "image/png",
      "expires": "1800s",
      "formattedExpires": "30 minutes"
    }
  ]
}

Security

  • Optional Bearer token auth
  • Rate limit per window
  • File size/type validation
  • Auto-delete with TTL

Contributing

  1. Fork this repo
  2. Create a branch feature-xyz
  3. Commit & push
  4. Open a pull request

$\frac{\text{Made with } \heartsuit \text{ by IRON-M4N}}{\text{2025 - 6969}}$

About

A lightweight and serverless CDN utilizing MEGA for file storage and delivery.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5