Skip to content

Latest commit

 

History

146 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 FormHub — Vercel Serverless Deployment

This directory contains the standalone, production-ready Vercel Serverless edition of FormHub.

It runs natively on Vercel Serverless Functions (Node.js) with persistent MongoDB Atlas integration, sub-100ms cold starts, and automatic global edge scaling.


📦 Project Structure

vercel/
├── api/
│   └── index.js              # Vercel Serverless Function entrypoint
├── src/
│   ├── auth.js               # JWT issue & verification (jose v6)
│   ├── crypto-utils.js       # PBKDF2 & AES-256-GCM encryption
│   ├── db.js                 # Serverless connection pool caching
│   ├── index.js              # Core Web Request Router
│   ├── security.js           # Security headers, CSP & bot verification
│   ├── shopify.js            # Shopify Admin API Metaobjects & Files sync
│   ├── validation.js         # Input validation, EXIF stripping, binary sniff
│   ├── routes/               # Modular API endpoint handlers
│   └── ui/                   # Full-featured Single-Page Dashboard & Form Builder
├── .env.example              # Environment variables template
├── .gitignore                # Vercel-specific gitignore
├── package.json              # Minimal serverless dependencies
├── vercel.json               # Vercel rewrite & function configuration
└── README.md                 # Deployment documentation

⚡ Deployment Methods

Method 1: Deploy with Vercel CLI (Fastest)

  1. Open your terminal in the vercel directory:
    cd vercel
  2. Run the Vercel deploy command:
    npx vercel
  3. When prompted, link or create your project.
  4. Deploy to production:
    npx vercel --prod

Method 2: Deploy via Vercel Web Dashboard (GitHub Integration)

  1. Go to vercel.com/new and import your GitHub repository.
  2. In the Project Settings:
    • Set Root Directory to vercel.
    • Framework Preset: Other.
  3. Under Environment Variables, add the required keys:
    • MONGODB_URI: Your MongoDB Atlas SRV connection string (e.g. mongodb+srv://user:pass@cluster0.mongodb.net/formhub?appName=FormHub).
    • JWT_SECRET: A secure 64-character random hex string.
    • ENCRYPTION_KEY: A secure 32-byte base64-encoded key.
    • (Optional) PLATFORM_TURNSTILE_SITE_KEY & PLATFORM_TURNSTILE_SECRET_KEY: For Cloudflare CAPTCHA bot protection.
    • (Optional) DASHBOARD_ALLOWED_ORIGINS: Set to * or your custom domain.
  4. Click Deploy.

🛡️ Key Serverless Enhancements

  • Connection Pool Caching: src/db.js caches the MongoClient instance across warm Lambda invocations to avoid exhausting database sockets.
  • Pure Web Standards: Leverages standard Request, Response, Headers, and crypto.subtle for fast, lightweight execution without heavy web framework overhead.
  • Auto-Routing: vercel.json routes all public endpoints (/api/:username/:appname/, /health, /, and dashboard SPA) through /api/index.js.

Releases

Packages

Contributors

Languages