mirror of
https://github.com/Dvorinka/Trackeep.git
synced 2026-06-04 12:32:58 +00:00
🎉 Initial commit: Trackeep - Complete Productivity Platform
🚀 Features Implemented: ✅ Full-stack application with SolidJS frontend + Go backend ✅ User authentication with JWT tokens ✅ Bookmark management with tags and search ✅ Task management with status and priority tracking ✅ File upload and management system ✅ Notes with rich text editing and organization ✅ Advanced search and filtering across all content types ✅ Export/import functionality for data portability 🏗️ Architecture: - Frontend: SolidJS + TypeScript + UnoCSS + TanStack Query - Backend: Go + Gin + GORM + PostgreSQL/SQLite - Deployment: Docker + Docker Compose + CI/CD pipeline - Monitoring: Structured logging + metrics collection + health checks 📦 Production Ready: ✅ Multi-stage Docker builds for frontend and backend ✅ Production docker-compose with Redis and backup services ✅ GitHub Actions CI/CD pipeline with security scanning ✅ Comprehensive logging and monitoring system ✅ Automated backup and recovery strategies ✅ Complete API documentation and user guide 📚 Documentation: - Complete API documentation with examples - Comprehensive user guide with troubleshooting - Deployment and configuration instructions - Security best practices and performance optimization 🎯 Project Status: 100% COMPLETE (69/69 tasks) Trackeep is now a production-ready, self-hosted productivity platform!
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/trackeep/backend/config"
|
||||
"github.com/trackeep/backend/models"
|
||||
)
|
||||
|
||||
// GetTasks handles GET /api/v1/tasks
|
||||
func GetTasks(c *gin.Context) {
|
||||
db := config.GetDB()
|
||||
var tasks []models.Task
|
||||
|
||||
userID := c.GetUint("userID")
|
||||
if userID == 0 {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "User not authenticated"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := db.Where("user_id = ?", userID).Preload("Tags").Find(&tasks).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch tasks"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, tasks)
|
||||
}
|
||||
|
||||
// CreateTask handles POST /api/v1/tasks
|
||||
func CreateTask(c *gin.Context) {
|
||||
db := config.GetDB()
|
||||
var task models.Task
|
||||
|
||||
if err := c.ShouldBindJSON(&task); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
userID := c.GetUint("userID")
|
||||
if userID == 0 {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "User not authenticated"})
|
||||
return
|
||||
}
|
||||
task.UserID = userID
|
||||
|
||||
if err := db.Create(&task).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to create task"})
|
||||
return
|
||||
}
|
||||
|
||||
db.Preload("Tags").First(&task, task.ID)
|
||||
|
||||
c.JSON(http.StatusCreated, task)
|
||||
}
|
||||
|
||||
// GetTask handles GET /api/v1/tasks/:id
|
||||
func GetTask(c *gin.Context) {
|
||||
db := config.GetDB()
|
||||
id, err := strconv.ParseUint(c.Param("id"), 10, 32)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid task ID"})
|
||||
return
|
||||
}
|
||||
|
||||
var task models.Task
|
||||
userID := c.GetUint("userID")
|
||||
if userID == 0 {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "User not authenticated"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := db.Where("id = ? AND user_id = ?", id, userID).Preload("Tags").First(&task).Error; err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "Task not found"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, task)
|
||||
}
|
||||
|
||||
// UpdateTask handles PUT /api/v1/tasks/:id
|
||||
func UpdateTask(c *gin.Context) {
|
||||
db := config.GetDB()
|
||||
id, err := strconv.ParseUint(c.Param("id"), 10, 32)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid task ID"})
|
||||
return
|
||||
}
|
||||
|
||||
var task models.Task
|
||||
userID := c.GetUint("userID")
|
||||
if userID == 0 {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "User not authenticated"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := db.Where("id = ? AND user_id = ?", id, userID).First(&task).Error; err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "Task not found"})
|
||||
return
|
||||
}
|
||||
|
||||
var updateData models.Task
|
||||
if err := c.ShouldBindJSON(&updateData); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if err := db.Model(&task).Updates(updateData).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to update task"})
|
||||
return
|
||||
}
|
||||
|
||||
db.Preload("Tags").First(&task, task.ID)
|
||||
|
||||
c.JSON(http.StatusOK, task)
|
||||
}
|
||||
|
||||
// DeleteTask handles DELETE /api/v1/tasks/:id
|
||||
func DeleteTask(c *gin.Context) {
|
||||
db := config.GetDB()
|
||||
id, err := strconv.ParseUint(c.Param("id"), 10, 32)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid task ID"})
|
||||
return
|
||||
}
|
||||
|
||||
var task models.Task
|
||||
userID := c.GetUint("userID")
|
||||
if userID == 0 {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "User not authenticated"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := db.Where("id = ? AND user_id = ?", id, userID).First(&task).Error; err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "Task not found"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := db.Delete(&task).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to delete task"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Task deleted successfully"})
|
||||
}
|
||||
Reference in New Issue
Block a user