Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Stars

20 stars

Watchers

0 watching

Forks

Repository files navigation

⚡ CloudPress

The Ultra-Fast, Serverless, Single-File CMS Built on Cloudflare Edge & D1 SQL

License: MIT Cloudflare Workers Cloudflare D1 Telegram Zero Dependencies Language: Bilingual

** مطالعه راهنما به زبان فارسی (Persian Documentation)** • 📢 کانال تلگرام (Telegram Channel)


🌟 Overview

CloudPress is a modern, lightweight, serverless Content Management System (CMS) and blogging platform engineered to run entirely on Cloudflare Workers with Cloudflare D1 SQL database.

Designed from the ground up to eliminate expensive traditional VPS hosting, database servers, and complicated maintenance, CloudPress delivers your content across 300+ edge data centers worldwide with sub-30ms TTFB (Time to First Byte).

The entire application runs from a single, self-contained worker file (worker.js) with zero server-side runtime npm dependencies.


✨ Key Features

  • 🚀 Serverless & Edge-First: Runs directly on Cloudflare’s global network with ultra-low latency worldwide.
  • 💾 Pure D1 SQL Storage: No external storage or AWS S3/Cloudflare R2 required. Images and assets are automatically compressed in the browser (WebP) and stored securely in SQLite tables.
  • ✍️ Visual WYSIWYG Editor (Quill.js):
    • Rich typography: Bold, Italic, Underline, Strikethrough, Code blocks, Blockquotes.
    • Heading styles (H1, H2, H3) and custom color pickers.
    • Bulleted and numbered lists with correct RTL/LTR indentations.
    • Video embeds (YouTube / Vimeo) and image insertions directly from the media library.
    • Source HTML view toggle for full developer freedom.
    • Live draft auto-saving to localStorage.
  • 🌍 100% Bilingual (English & Persian):
    • Global English (LTR layout, typography powered by Google Inter).
    • Native Persian (RTL layout, typography powered by Vazirmatn).
    • Bidirectional, real-time UI switching with dynamic translation engine.
  • 🎨 Full Homepage Customization:
    • Customizable Hero section (Badge, Title, Description, CTA Buttons, Hero Image).
    • Customizable 3-column Features grid (Titles, Descriptions, Icons).
    • Header navigation menu builder with drag-and-drop hierarchy.
    • Custom CSS & Head/Footer script injections (Google Analytics, live chat widgets).
  • 💬 Interactive Comments & Moderation:
    • Public comment submission with Honeypot anti-spam protection.
    • Toggle between auto-approval and manual admin moderation.
  • 📈 Real Analytics Counter:
    • Real database-driven article view counter (views_count in D1 SQL).
    • Aggregated dashboard stats (Total Articles, Pages, Comments, Views).
  • 🔍 Built-in Edge SEO:
    • Auto-generated XML Sitemap (/sitemap.xml).
    • Search engine crawler directives (/robots.txt).
    • Auto-generated RSS 2.0 Feed (/rss.xml and /feed.xml).
    • OpenGraph & JSON-LD structured data on all posts and pages.
  • 📦 One-Click Backup & Restore:
    • Export complete site data (Posts, Pages, Categories, Settings, Comments) as a single portable JSON file.
    • Instant one-click import restoration.

🏗 Architecture

┌─────────────────────────────────────────────────────────────┐
│                   Global Cloudflare Edge                    │
├───────────────────────────────┬─────────────────────────────┤
│         Public Web            │         Admin SPA           │
│  - Homepage & Hero Section    │  - Dashboard & Analytics    │
│  - Blog Archive & Real-time   │  - Quill WYSIWYG Editor     │
│  - Clean Slugs (/blog, /post) │  - Media Library (WebP)     │
│  - Dynamic XML Sitemap & RSS  │  - Menu Builder & Settings  │
│  - Bilingual (LTR & RTL)      │  - Backup Export / Import   │
├───────────────────────────────┴─────────────────────────────┤
│                      worker.js                              │
│              (Single Self-Contained Engine)                 │
├─────────────────────────────────────────────────────────────┤
│                 Cloudflare D1 (Serverless SQL)              │
│      [posts]  [pages]  [categories]  [media]  [settings]    │
└─────────────────────────────────────────────────────────────┘

🚀 Deployment Guides

Choose the deployment method that fits you best:


🌐 Option A: Cloudflare Web Dashboard (3 Minutes, No Terminal)

You do not need Git, Node.js, or any command line tools installed. You can launch your entire CMS directly inside your web browser using the free Cloudflare dashboard:

Step 1: Create a D1 Database

  1. Log into your Cloudflare Dashboard.
  2. In the left navigation menu, go to Storage & Databases ➔ D1 SQL Database.
  3. Click Create ➔ Name your database cloudpress_db ➔ Click Create.

Step 2: Create the Worker

  1. In the left sidebar, click Compute (Workers & Pages) ➔ Click Create ➔ Create Worker.
  2. Give your worker a name (e.g. my-blog or cloudpress) and click Deploy.
  3. On the confirmation screen, click Edit code to open Cloudflare's in-browser editor.
  4. Delete all existing sample code.
  5. Copy the entire content of worker.js, paste it into the editor, and click Deploy (top right).

Step 3: Link D1 Database & Enable Node.js Compatibility (Crucial)

  1. Go back to your Worker's main page in the dashboard and click the Settings tab.
  2. Under Bindings (or D1 Database Bindings), click Add ➔ Select D1 Database:
    • Variable name: DB (Must be uppercase DB)
    • D1 database: Select cloudpress_db
    • Click Save and deploy.
  3. Under the same Settings tab, scroll to Runtime (or Compatibility Flags):
    • Under Compatibility flags, add: nodejs_compat
    • Click Save.

Step 4: Set Mandatory JWT Secret (Security Critical)

  1. Still under Worker Settings, click Variables and Secrets.
  2. Under Secrets, click Add:
    • Type: Select Secret (encrypted)
    • Variable name: JWT_SECRET
    • Value: Enter a high-entropy secret string (e.g. generated via openssl rand -base64 48)
  3. Click Deploy. (Note: CloudPress fails closed and will refuse to serve admin routes without JWT_SECRET set, preventing unauthorized takeover).

Step 5: Access Your New Site & Update Credentials 🎉

  • Public Site: Open https://your-worker-name.<subdomain>.workers.dev
  • Admin Panel: Go to https://your-worker-name.<subdomain>.workers.dev/admin
  • Initial Credentials:
    • Username: admin
    • Password: admin123 (The database schema and initial pages are created automatically on your first visit!)

    ⚠️ Mandatory Security Requirement: Upon first login, CloudPress requires changing the default administrator password in your Profile section. Changing the password instantly revokes all existing active sessions.


💻 Option B: Developer CLI (Wrangler & Local Dev)

Prerequisites

1. Clone the Repository

git clone https://github.com/your-username/cloudpress.git
cd cloudpress

2. Install Dependencies

npm install

3. Create your Cloudflare D1 Database

Login to your Cloudflare account via Wrangler:

npx wrangler login

Create a new D1 database named cloudpress_db:

npx wrangler d1 create cloudpress_db

The command will output your database ID:

database_name = "cloudpress_db"
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

4. Configure wrangler.toml & Local Secret

Open wrangler.toml and paste your database_id:

[[d1_databases]]
binding = "DB"
database_name = "cloudpress_db"
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

For local testing, create a .dev.vars file in the project root:

JWT_SECRET=your-secure-local-jwt-secret-key-at-least-32-chars

5. Run Locally

npm run dev

Open http://localhost:8787 in your browser:

  • Frontend: http://localhost:8787/
  • Admin Panel: http://localhost:8787/admin
  • Initial Credentials: admin / admin123 (prompted to change immediately)

🚢 Deploy to Production

  1. Set your production JWT secret:
npx wrangler secret put JWT_SECRET
  1. Deploy with one command directly to Cloudflare's global edge network:
npm run deploy

🧪 Comprehensive Automated Testing

CloudPress includes an automated security and functional verification suite:

  • Cryptographic hash strength (PBKDF2 100,000 iterations & legacy migration)
  • Constant-time HMAC signature verification (timingSafeEqual)
  • Session revocation on password changes (token_version)
  • HTTP security response headers (X-Frame-Options, nosniff, HSTS)
  • Safe backup import allowlist filtering (persistent XSS prevention)
  • Comment payload limits & moderation defaults
  • Brute-force rate limiting and fail-closed secret checks

To run the complete automated test suite:

npm test
Result:
```text
================================================================================
🏁 TEST SUITE COMPLETED: 54 PASSED, 0 FAILED
================================================================================

🔒 Security

  • JWT Session Protection: HMAC SHA-256 tokens stored in HttpOnly, SameSite=Lax, Secure cookies.
  • Salted Password Hashing: Cryptographic PBKDF2/SHA-256 with unique per-user salts.
  • Honeypot Anti-Spam: Invisible bot-detection fields on public comment forms.
  • Admin Path Cloaking: Admin login buttons are completely omitted from public layouts.
  • SQL Injection Defense: All database operations use prepared parameter bindings (db.prepare().bind()).

📢 Community & Support

Join our official Telegram channel for updates, announcements, and support:


📄 License

This project is licensed under the MIT License - developed by Qorvhex. Free for personal and commercial use.

About

No description, website, or topics provided.

Resources

Contributing

Stars

20 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages