From 551c75a232d06a374cd36c878ac37489d62803b4 Mon Sep 17 00:00:00 2001 From: Vladimir Zagainov Date: Sat, 23 May 2026 17:57:37 +0300 Subject: [PATCH] chore: initial project structure --- .gitignore | 21 +++++++++++++++++++++ README.md | 25 +++++++++++++++++++++++++ cmd/server/main.go | 26 ++++++++++++++++++++++++++ go.mod | 3 +++ internal/admin/admin.go | 2 ++ internal/api/api.go | 3 +++ internal/auth/auth.go | 2 ++ internal/cas/cas.go | 2 ++ internal/config/config.go | 2 ++ internal/database/database.go | 2 ++ internal/middleware/middleware.go | 2 ++ internal/templates/templates.go | 2 ++ pkg/utils/utils.go | 2 ++ 13 files changed, 94 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 cmd/server/main.go create mode 100644 go.mod create mode 100644 internal/admin/admin.go create mode 100644 internal/api/api.go create mode 100644 internal/auth/auth.go create mode 100644 internal/cas/cas.go create mode 100644 internal/config/config.go create mode 100644 internal/database/database.go create mode 100644 internal/middleware/middleware.go create mode 100644 internal/templates/templates.go create mode 100644 pkg/utils/utils.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7261d3a --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# Binaries +*.exe +*.dll +*.so +*.dylib +*.test +*.out + +# Go +vendor/ +go.sum + +# IDE +.idea/ +.vscode/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db diff --git a/README.md b/README.md new file mode 100644 index 0000000..4cea7a2 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# MrixsCraft Server + +Minecraft серверная часть на Go (net/http + PostgreSQL). + +## Сборка + +```bash +go build -o mrixscraft-server ./cmd/server +``` + +## Запуск + +```bash +export SERVER_PORT=8080 +export DATABASE_URL="postgres://user:pass@localhost:5432/mrixscraft" + +go run ./cmd/server +``` + +## Переменные окружения + +| Переменная | Описание | По умолчанию | +|------------|----------|--------------| +| `SERVER_PORT` | Порт HTTP-сервера | `8080` | +| `DATABASE_URL` | DSN PostgreSQL | — | diff --git a/cmd/server/main.go b/cmd/server/main.go new file mode 100644 index 0000000..cc8a074 --- /dev/null +++ b/cmd/server/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "log" + "net/http" + "os" +) + +func main() { + port := os.Getenv("SERVER_PORT") + if port == "" { + port = "8080" + } + + mux := http.NewServeMux() + mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + fmt.Fprintln(w, "ok") + }) + + log.Printf("MrixsCraft Server starting on :%s", port) + if err := http.ListenAndServe(":"+port, mux); err != nil { + log.Fatal(err) + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..22d04eb --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/Mrixs/MrixsCraft-server + +go 1.22 diff --git a/internal/admin/admin.go b/internal/admin/admin.go new file mode 100644 index 0000000..810e714 --- /dev/null +++ b/internal/admin/admin.go @@ -0,0 +1,2 @@ +// package admin implements admin panel endpoints (modpack management, CI/CD release). +package admin diff --git a/internal/api/api.go b/internal/api/api.go new file mode 100644 index 0000000..b1e1070 --- /dev/null +++ b/internal/api/api.go @@ -0,0 +1,3 @@ +// Package api implements public HTTP endpoints for the launcher and website. +package api + diff --git a/internal/auth/auth.go b/internal/auth/auth.go new file mode 100644 index 0000000..0283f6c --- /dev/null +++ b/internal/auth/auth.go @@ -0,0 +1,2 @@ +// Package auth implements Yggdrasil authentication protocol. +package auth diff --git a/internal/cas/cas.go b/internal/cas/cas.go new file mode 100644 index 0000000..52f6238 --- /dev/null +++ b/internal/cas/cas.go @@ -0,0 +1,2 @@ +// package cas implements Content-Addressable Storage for files (mods, assets, etc). +package cas diff --git a/internal/config/config.go b/internal/config/config.go new file mode 100644 index 0000000..d912805 --- /dev/null +++ b/internal/config/config.go @@ -0,0 +1,2 @@ +// package config handles server configuration (env vars, config files). +package config diff --git a/internal/database/database.go b/internal/database/database.go new file mode 100644 index 0000000..28b927f --- /dev/null +++ b/internal/database/database.go @@ -0,0 +1,2 @@ +// package database manages PostgreSQL connections, migrations, and data models. +package database diff --git a/internal/middleware/middleware.go b/internal/middleware/middleware.go new file mode 100644 index 0000000..57f4d00 --- /dev/null +++ b/internal/middleware/middleware.go @@ -0,0 +1,2 @@ +// package middleware provides HTTP middleware (JWT, CORS, rate limiting, logging). +package middleware diff --git a/internal/templates/templates.go b/internal/templates/templates.go new file mode 100644 index 0000000..443604c --- /dev/null +++ b/internal/templates/templates.go @@ -0,0 +1,2 @@ +// package templates handles Go html/template rendering for the site and admin panel. +package templates diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go new file mode 100644 index 0000000..e9c09c6 --- /dev/null +++ b/pkg/utils/utils.go @@ -0,0 +1,2 @@ +// package utils provides shared utility functions (SHA-1, ZIP, etc.). +package utils