A modern Wikitext Previewer API built with Hono, PostgreSQL, Docker, and Bun runtime. This project provides a RESTful API for creating, updating, and managing wiki pages with full revision history tracking.
- 📝 Create and update wiki pages
- 📚 Full revision history tracking
- 🔄 Automatic revision counting
- 🐳 Docker and Docker Compose setup
- 🗄️ PostgreSQL database with migrations
- 🛡️ Type-safe SQL with Kysely (no raw SQL!)
- 🚀 Bun runtime for better performance
- 📦 Distroless Docker image (~100MB)
- 🔒 Optional password protection (future feature)
- 🌐 CORS support for web applications
- 🚀 FTML parsing and rendering via WebAssembly API
- Docker and Docker Compose
- Bun 1.0+ (for local development) - Install Bun
- PostgreSQL (if not using Docker)
- Node.js 18+ (optional, for compatibility)
- Clone the repository:
git clone <repository-url>
cd wikitext-backend
- Quick start with Make:
make quick-start
This will:
- Copy
.env.example
to.env
- Start all Docker services
- Run database migrations
- Make the API available at
http://localhost:3000
cp .env.example .env
docker compose up -d
docker compose run --rm migrate
- Install dependencies:
bun install
- Set up environment variables:
cp .env.example .env
# Edit .env with your database credentials
- Run database migrations:
bun run migrate:up
- Start the development server:
bun run dev
GET /v1/health
POST /v1/data
Body: {
"title": "Page Title",
"source": "Wiki content",
"createdBy": "username"
}
PATCH /v1/data/:shortId
Body: {
"title": "Updated Title",
"source": "Updated content",
"createdBy": "username"
}
GET /v1/data/:shortId
POST /v1/data/:shortId/history
POST /v1/data/:shortId/revision/:revisionId
wikitext-backend/
├── src/
│ ├── config/ # Configuration files
│ ├── db/ # Database connection and queries
│ ├── models/ # TypeScript interfaces
│ ├── utils/ # Utility functions
│ └── index.ts # Main application entry
├── db/
│ └── migrations/ # SQL migration files
├── compose.yml # Docker Compose configuration
├── Dockerfile # Docker image definition
└── package.json # Node.js dependencies
Run make help
to see all available commands. Common ones include:
make dev
- Start development server locallymake up
- Start all Docker servicesmake down
- Stop all servicesmake logs
- View application logsmake migrate
- Run database migrationsmake db-shell
- Access PostgreSQL shellmake shell
- Access application containermake status
- Check status of all services
bun run dev
- Start development server with hot reloadbun run build
- Build TypeScript to JavaScriptbun start
- Start production serverbun run migrate:up
- Run pending migrationsbun run migrate:status
- Check migration statusbun run typecheck
- Run TypeScript type checking
Create a new migration:
# Create a new SQL file in db/migrations/
# Name format: 00X_description.sql
Run migrations:
bun run migrate:up
Check migration status:
bun run migrate:status
# Build the image
docker build -t wikitext-backend .
# Run with docker compose
docker compose up -d
# View logs
docker compose logs -f app
# Stop services
docker compose down
# Access PostgreSQL
docker compose exec postgres psql -U wikitext
# Run migrations
docker compose run --rm migrate
# Access pgAdmin (if enabled)
# Visit http://localhost:5050
See .env.example
for all available environment variables:
PORT
- Server port (default: 3000)DATABASE_URL
- PostgreSQL connection stringCORS_ORIGINS
- Allowed CORS originsNODE_ENV
- Environment (development/production)
- 🌐 Wikidot integration using scp-jp-utilities
- 🔐 Enhanced authentication and authorization
- 🔄 Real-time collaboration features
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.