feat: implement WYSIWYG markdown editor
Add full-stack markdown editor with Go backend and React frontend. Backend: - Cobra CLI with --data-dir, --port, --host flags - REST API for markdown file CRUD operations - File storage with flat directory structure - logrus logging for all operations - Static file serving for frontend - Comprehensive tests for CRUD and static assets Frontend: - React + TypeScript + Vite + Tailwind CSS - Live markdown preview with marked (GFM) - File management: list, create, open, save, delete - Theme system: Dark/Light/System with persistence - Responsive design (320px to 1920px) - Component tests for Editor, Preview, Sidebar Build: - Makefile for build, test, and run automation - Single command testing (make test) Closes SPEC.md requirements
This commit is contained in:
53
backend/main.go
Normal file
53
backend/main.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"markdown-editor-backend/server"
|
||||
)
|
||||
|
||||
var (
|
||||
dataDir string
|
||||
port int
|
||||
host string
|
||||
log = logrus.New()
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "markdown-editor-backend",
|
||||
Short: "WYSIWYG Markdown Editor Backend",
|
||||
Long: `A Go backend server for the WYSIWYG Markdown Editor with CRUD operations for markdown files.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
log.SetFormatter(&logrus.TextFormatter{
|
||||
FullTimestamp: true,
|
||||
})
|
||||
log.SetLevel(logrus.InfoLevel)
|
||||
|
||||
log.WithFields(logrus.Fields{
|
||||
"dataDir": dataDir,
|
||||
"host": host,
|
||||
"port": port,
|
||||
}).Info("Starting server")
|
||||
|
||||
srv := server.New(dataDir, host, port, log)
|
||||
if err := srv.Start(); err != nil {
|
||||
log.WithError(err).Fatal("Server failed to start")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.Flags().StringVar(&dataDir, "data-dir", "./data", "Storage path for markdown files")
|
||||
rootCmd.Flags().IntVar(&port, "port", 8080, "Server port")
|
||||
rootCmd.Flags().StringVar(&host, "host", "127.0.0.1", "Bind address")
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user