Skip to content

Latest commit

 

History

History
293 lines (217 loc) · 9.43 KB

README.md

File metadata and controls

293 lines (217 loc) · 9.43 KB
DevToolsHub logo

DevToolsHub

Free, fast, and developer-friendly online tools — no installation required.

Website Next.js MongoDB License


✨ Tools

Tool URL Description
🔧 JSON Formatter /json-format-vertical Validate & pretty-print JSON with syntax highlighting
🔄 XML ↔ JSON /xml-to-json-vertical Convert between XML and JSON instantly
🔑 JWT Decoder /jwt-decode Inspect JWT header, payload, and signature
🔒 Base64 /base64 Encode and decode Base64 strings
🖼️ Image ↔ Base64 /image-to-base64 Convert images to Base64 (or render Base64 back), with full image info & EXIF
📡 Morse Code /morse-code-decoder Translate text ↔ Morse code with audio playback
📱 QR Code /qr-code-generator Create custom QR codes with logo & color support
🌐 HTML Render /html-render Live HTML/CSS/JS preview with resizable split pane
📬 Temp Mail /temp-mail Disposable inbox that self-destructs — no signup

🛠️ Tech Stack

Layer Technology
Framework Next.js 15 — Pages Router
Language TypeScript
Styling Tailwind CSS + daisyUI
Animation Framer Motion
Auth NextAuth.js (Google OAuth)
Database MongoDB via Mongoose
Icons Heroicons
Alerts SweetAlert2
State Recoil
Deployment Vercel

🚀 Getting Started

Prerequisites

  • Node.js ≥ 18
  • MongoDB Atlas cluster (or local instance)
  • Google OAuth credentials — create here

Installation

# 1. Clone the repository
git clone https://github.com/Mark-Notify/devtoolshub.git
cd devtoolshub

# 2. Install dependencies
npm install       # or: yarn install

# 3. Configure environment variables
cp .env.example .env.local
# → Fill in MONGODB_URI, NEXTAUTH_SECRET, GOOGLE_CLIENT_ID, etc.

# 4. Start the dev server
npm run dev       # or: yarn dev

Open http://localhost:3000 in your browser.

Build for Production

npm run build     # runs: next build
npm run start

🌐 API Reference

All routes live under /api/.

🔍 Health Check

Method Endpoint Auth Description
GET /api/health — Check server & MongoDB connection status

200 Response:

{ "status": "ok", "db": "connected", "timestamp": "2024-01-01T00:00:00.000Z" }

503 Response (DB unreachable):

{ "status": "error", "db": "disconnected", "message": "Database connection failed" }

📜 History

History is strictly per-user — users only see their own records. A public share link can be generated for individual entries.

Method Endpoint Auth Description
GET /api/get-data ✅ Session List the current user's history (newest first)
POST /api/save-data ✅ Session Save a new history entry
PATCH /api/get-data ✅ Session Generate a public share link for one entry
GET /api/history/share/[id] — Public View a single entry via its shareId
GET /api/history/cleanup 🔐 CRON_SECRET Delete all entries older than 1 month

Generate a share link

Request:

PATCH /api/get-data
Content-Type: application/json

{ "id": "<MongoDB _id>" }

Response:

{ "shareId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" }

Share URL: https://www.devtoolshub.org/api/history/share/<shareId>

The share endpoint returns only tool, inputData, outputData, and createdAt — userEmail is never exposed.


⭐ Favorites

Method Endpoint Auth Description
GET /api/favorites ✅ Session List favorited tools
POST /api/favorites ✅ Session Add a tool to favorites
DELETE /api/favorites ✅ Session Remove a tool from favorites

💾 Snippets

Method Endpoint Auth Description
GET /api/snippets ✅ Session List saved snippets
POST /api/snippets ✅ Session Create a snippet
PUT /api/snippets ✅ Session Update a snippet
DELETE /api/snippets ✅ Session Delete a snippet

⚙️ Environment Variables

Copy .env.example to .env.local and fill in the values:

# MongoDB
MONGODB_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/devtoolshub

# NextAuth.js
NEXTAUTH_SECRET=<random 32-byte base64>
NEXTAUTH_URL=http://localhost:3000

# Google OAuth
GOOGLE_CLIENT_ID=<your-client-id>.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=<your-client-secret>

# Cron job secret (protects /api/history/cleanup)
CRON_SECRET=<random 32-byte base64>

# Temp Mail — comma separated; the first one is the default for Free users
TEMP_MAIL_DOMAINS=mail.example.com,inbox.example.com

# Shared secret between the Cloudflare Email Worker and /api/temp-mail/inbound
TEMP_MAIL_INBOUND_SECRET=<random 32-byte base64>

Generate a secret:

openssl rand -base64 32

🕐 Cron Jobs

vercel.json configures Vercel Cron to call /api/history/cleanup on the 1st of every month at 02:00 UTC.

The endpoint requires:

Authorization: Bearer <CRON_SECRET>

📬 Temp Mail

Disposable inboxes at /temp-mail. Vercel cannot run an SMTP server, so mail is accepted by Cloudflare Email Routing and pushed into the app as JSON.

Next.js UI ──► /api/temp-mail/* ──► MongoDB (mailboxes + messages, TTL indexes)
                     ▲
                     │ POST /api/temp-mail/inbound  (x-tempmail-secret)
                     │
        Cloudflare Email Worker ◄── Cloudflare MX ◄── Internet Mail

Mailbox and message documents carry an expiresAt TTL index, so MongoDB deletes them on its own — no Redis or queue worker to run.

Free Pro
Lifetime 10 minutes 24 hours
Mailboxes 1 5
Read mail ✅ ✅
Attachments ❌ ✅ (1 MB/file, 4 MB/mail)
Custom prefix + domain ❌ ✅

Pro has no payment flow yet. It is granted by an allow-list in MongoDB — sign in with Google, and Pro applies if that email is in the prowhitelists collection:

db.prowhitelists.insertOne({ email: "someone@gmail.com", active: true, createdAt: new Date() })

Setting up the mail path is documented in workers/temp-mail-inbound/README.md.


📁 Project Structure

devtoolshub/
├── components/
│   ├── HtmlEditor/          # Live HTML/CSS/JS preview (split-pane)
│   ├── JsonFormat/          # JSON formatter & XML converter
│   ├── Jwt/                 # JWT decoder
│   ├── Layout/              # Header + responsive sidebar
│   ├── QRCode/              # QR code generator
│   └── ...
├── models/                  # Mongoose schemas
│   ├── UserData.ts          # History entries (with optional shareId)
│   ├── Favorite.ts
│   ├── SavedSnippet.ts
│   └── UserPreferences.ts
├── lib/
│   └── mongodb.ts           # Singleton MongoDB connection helper
├── pages/
│   ├── api/
│   │   ├── health.ts        # GET  — DB health check
│   │   ├── get-data.tsx     # GET/PATCH — user history + share link
│   │   ├── save-data.tsx    # POST — save history entry
│   │   ├── history/
│   │   │   ├── cleanup.ts   # GET  — cron: delete entries >1 month
│   │   │   └── share/
│   │   │       └── [id].ts  # GET  — public share endpoint
│   │   ├── favorites.ts
│   │   ├── snippets.ts
│   │   └── auth/
│   ├── [slug].tsx           # Dynamic tool pages
│   └── index.tsx
├── public/                  # Static assets & logo
├── vercel.json              # Cron job configuration
└── .env.example             # Environment variable template

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feat/my-feature
  3. Commit your changes: git commit -m "feat: add my feature"
  4. Push and open a Pull Request

📝 License

MIT © DevToolsHub