A modern, fast, full-featured Weblog Content Management System (CMS) built entirely on Bun and SQLite (bun:sqlite).
weblogcms provides a complete blog publishing platform featuring multi-blog support, rich post & page lifecycle management, comment moderation, customizable gadget layout widgets, built-in analytics, RSS feeds, backup export/import, and flatfile JSON synchronization.
- ⚡ Native Bun Performance: Built directly on
Bun.serve()and nativebun:sqlitefor sub-millisecond response times. - 📰 Multi-Blog & Custom Slugs: Create and manage multiple blogs with distinct slugs, descriptions, themes, and settings.
- ✍️ Content Lifecycle Management:
- Posts: Rich post management supporting states (
published,draft,scheduled,trash), tags/labels, meta descriptions, and page-view tracking. - Pages: Static pages with custom URL slugs and SEO meta descriptions.
- Posts: Rich post management supporting states (
- 💬 Comment Moderation Workflow: Automated and manual comment moderation statuses (
approved,pending,spam,trash). - 🧩 Dynamic Gadgets & Layout Manager: Modular layout system with customizable widgets (HTML, Text, Header, Pages, Archive, Labels, Profile, Stats, Search) and position ordering.
- 📊 Built-in Analytics: Lightweight visitor analytics tracking referral URLs, user agents, IP addresses, and view counts.
- 📡 RSS & Atom Feed Generator: Built-in RSS feeds (
/feed.xml,/rss,/:slug/feed.xml) for post distribution. - 💾 Dual Storage Architecture: Primary SQLite database storage (
weblog.db) with support for flatfile JSON file syncing (flatfile.ts). - 🔐 Authentication & Sessions: Secure admin authentication using hashed credentials, session tokens, and cookie/header authorization (
db.ts). - 📦 Backup Export & Import: Complete system backup export and restoration via JSON data transfer.
- 📱 Single-Page Application & PWA Ready: Interactive frontend app in
public/app.jswith service worker support (public/sw.js).
.
├── index.ts # HTTP server, routing, API endpoints & static serving
├── db.ts # SQLite database schema, initialization & query helpers
├── flatfile.ts # Flatfile JSON storage reader, writer & sync utilities
├── index.test.ts # Complete test suite for CMS database & HTTP APIs
├── public/ # Frontend single-page application assets
│ ├── app.js # Admin dashboard and blog frontend application logic
│ ├── index.html # SPA entrypoint HTML layout
│ ├── styles.css # Modern CSS styling framework
│ └── sw.js # Service worker for offline & PWA caching
├── package.json # Bun project metadata and script commands
├── tsconfig.json # TypeScript configuration
└── CLAUDE.md # Development guidelines and Bun API usage notes
- Bun (v1.0.0 or higher)
-
Clone the repository:
git clone https://github.com/Sparky4567/weblogcms.git cd weblog -
Install dependencies:
bun install
-
Development Mode (with Hot Reloading):
bun run dev
Or directly:
bun --hot index.ts -
Production Mode:
bun start
The server runs at http://localhost:3000 by default. You can change the port using the PORT environment variable:
PORT=8080 bun startWhen the application runs for the first time, a default administrator account is automatically created:
- Username:
admin - Password:
admin123
💡 Tip: You can change your admin username and password at any time via the admin dashboard settings or using the
PUT /api/auth/credentialsAPI endpoint.
Run the automated test suite using Bun's native test runner:
bun testThe test suite covers:
- Database initialization and seed data verification
- Multi-blog querying and post filtering
- Post, page, comment, and gadget CRUD workflows
- Comment moderation logic
- Admin login, session validation, and credential management
- Backup export and import functionality
- Flatfile storage saving and synchronization
POST /api/auth/login- Authenticate admin credentials and generate session tokenPOST /api/auth/logout- Invalidate active session tokenGET /api/auth/check- Validate session statusPUT /api/auth/credentials- Update admin username/password
GET /api/blogs- List all weblogsPOST /api/blogs- Create a new weblogGET /api/blogs/:id- Fetch single blog detailsPUT /api/blogs/:id- Update weblog details and settingsDELETE /api/blogs/:id- Delete weblog and related posts
GET /api/posts?blog_id=:id&status=:status- List posts with optional filtersPOST /api/posts- Create postGET /api/posts/:id- Get post by IDPUT /api/posts/:id- Update post title, content, status, tags, etc.DELETE /api/posts/:id- Delete post
GET /api/pages?blog_id=:id- List static pagesPOST /api/pages- Create a static pageGET /api/pages/:id- Get page by IDPUT /api/pages/:id- Update static pageDELETE /api/pages/:id- Delete static page
GET /api/comments?post_id=:id&status=:status- List commentsPOST /api/comments- Submit new commentPUT /api/comments/:id- Moderate comment (approve, spam, trash)DELETE /api/comments/:id- Delete comment
GET /api/gadgets?blog_id=:id- List gadgets for a blogPOST /api/gadgets- Add new gadget widgetPUT /api/gadgets/reorder- Update widget ordering positionsPUT /api/gadgets/:id- Update gadget configurationDELETE /api/gadgets/:id- Delete gadget
POST /api/track- Log page view eventGET /api/stats?blog_id=:id- Retrieve blog analyticsGET /api/export- Export full database to JSONPOST /api/import- Import database from JSON backupGET /api/flatfile/settings- Read flatfile settingsPOST /api/flatfile/sync- Synchronize database blogs to JSON flatfileGET /feed.xml/GET /rss- Dynamic RSS feed generation
This project is open-source and licensed under the MIT License.