Compare commits

..

15 Commits

44 changed files with 245 additions and 93 deletions
+18 -7
View File
@@ -7,15 +7,13 @@ import (
"net/http"
"os"
"path/filepath"
"time"
"github.com/alexedwards/scs/v2"
"github.com/joho/godotenv"
)
func handler(writer http.ResponseWriter, request *http.Request) {
templ := template.Must(template.ParseFiles("./web/dist/index.html"))
templ.Execute(writer, nil)
}
var sessionManager *scs.SessionManager
func main() {
err := godotenv.Load()
@@ -23,10 +21,16 @@ func main() {
log.Fatal("Error loading .env file")
}
// handle authentication
sessionManager = scs.New()
sessionManager.Lifetime = 24 * time.Hour
// handle frontend views
webDir := "./web/dist"
fs := http.FileServer(http.Dir(webDir))
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
http.Handle("/", sessionManager.LoadAndSave(
http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
if request.URL.Path != "/" {
path := filepath.Join(webDir, filepath.Clean(request.URL.Path))
_, err := os.Stat(path)
@@ -36,7 +40,8 @@ func main() {
}
}
handler(writer, request)
})
}),
))
port := os.Getenv("HTTP_PORT")
if port == "" {
@@ -48,3 +53,9 @@ func main() {
log.Fatalf("server error: %v", err)
}
}
func handler(writer http.ResponseWriter, request *http.Request) {
templ := template.Must(template.ParseFiles("./web/dist/index.html"))
templ.Execute(writer, nil)
}
+5 -1
View File
@@ -2,4 +2,8 @@ module solopm.com/solopm-server
go 1.26.3
require github.com/joho/godotenv v1.5.1 // indirect
require (
github.com/alexedwards/scs/v2 v2.9.0 // indirect
github.com/golang-migrate/migrate/v4 v4.19.1 // indirect
github.com/joho/godotenv v1.5.1 // indirect
)
+4
View File
@@ -1,2 +1,6 @@
github.com/alexedwards/scs/v2 v2.9.0 h1:xa05mVpwTBm1iLeTMNFfAWpKUm4fXAW7CeAViqBVS90=
github.com/alexedwards/scs/v2 v2.9.0/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gvmdl7h3RRj8=
github.com/golang-migrate/migrate/v4 v4.19.1 h1:OCyb44lFuQfYXYLx1SCxPZQGU7mcaZ7gH9yH4jSFbBA=
github.com/golang-migrate/migrate/v4 v4.19.1/go.mod h1:CTcgfjxhaUtsLipnLoQRWCrjYXycRz/g5+RWDuYgPrE=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
+35
View File
@@ -0,0 +1,35 @@
package db
import (
"database/sql",
"log"
"github.com/golang-migrate/migrate/v4"
"github.com/golang-migrate/migrate/v4/database/sqlite3"
_ "github.com/golang-migrate/migrate/v4/source/file"
_ "github.com/mattn/go-sqlite3"
)
func main() {
db, err := sql.Open("sqlite3", "database.sqlite")
if err != nil {
log.Fatal(err)
}
defer db.Close()
driver, err := sqlite3.WithInstance(db, &sqlite3.Config{})
if err != nil {
log.Fatal(err)
}
migrator, err := migrate.NewWithDatabaseInstance(
"file://migrations/", "sqlite3", driver
)
if err != nil {
log.Fatal(err)
}
if err := migrator.Up(); err != nill && err != migrate.ErrNoChange {
log.Fatal(err)
}
}
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_00_00_000000_create_audit_log_table.sql.down.sql
-- DROP TABLE "audit_log" --------------------------------------
DROP TABLE IF EXISTS "audit_log";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_00_00_000000_create_audit_log_table.sql
-- internal/db/migrations/2026_00_00_000000_create_audit_log_table.sql.up.sql
-- CREATE TABLE "audit_log" ------------------------------------
CREATE TABLE IF NOT EXISTS "audit_log" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000000_create_users_table.sql.down.sql
-- DROP TABLE "users" ------------------------------------------
DROP TABLE IF EXISTS "users";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000000_create_users_table.sql
-- internal/db/migrations/2026_01_01_000000_create_users_table.sql.up.sql
-- CREATE TABLE "users" ----------------------------------------
CREATE TABLE IF NOT EXISTS "users" (
@@ -27,17 +27,17 @@ CREATE UNIQUE INDEX IF NOT EXISTS "idx_users_provider"
-- -------------------------------------------------------------
-- INSERT "SYSTEM" USER ----------------------------------------
INSERT INTO `users`
(`username`,`is_admin`,`name`,`email`,`avatar_url`)
INSERT INTO users
(username,is_admin,name,email,avatar_url)
VALUES
("system", true, "System User", "system@localhost", "")
('system', true, 'System User', 'system@localhost', '/uploads/avatars/system.png')
;
-- -------------------------------------------------------------
-- INSERT "ZOMBIE" USER ----------------------------------------
INSERT INTO `users`
(`username`,`is_admin`,`name`,`email`,`avatar_url`)
INSERT INTO users
(username,is_admin,name,email,avatar_url)
VALUES
("zombie", false, "Zombie", "zombie@localhost", "")
('zombie', false, 'Zombie', 'zombie@localhost', '/uploads/avatars/zombie.png')
;
-- -------------------------------------------------------------
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000010_create_projects_table.sql.down.sql
-- DROP TABLE "projects" ---------------------------------------
DROP TABLE IF EXISTS "projects";
-- -------------------------------------------------------------
@@ -1,6 +1,6 @@
-- internal/db/migrations/2026_01_01_000010_create_projects_table.sql
-- internal/db/migrations/2026_01_01_000010_create_projects_table.sql.up.sql
-- CREATE TABLE "projects" ------------------------------------
-- CREATE TABLE "projects" -------------------------------------
CREATE TABLE IF NOT EXISTS "projects"(
"id" Integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"creator_id" Integer NOT NULL REFERENCES "users"("id"),
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000011_create_project_user_table.sql.down.sql
-- DROP TABLE "project_user" -----------------------------------
DROP TABLE IF EXISTS "project_user";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000011_create_project_user_table.sql
-- internal/db/migrations/2026_01_01_000011_create_project_user_table.sql.up.sql
-- CREATE TABLE "project_user" ---------------------------------
CREATE TABLE IF NOT EXISTS "project_user" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000011_create_project_labels_table.sql.down.sql
-- DROP TABLE "project_labels" ---------------------------------
DROP TABLE IF EXISTS "project_labels";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000011_create_project_labels_table.sql
-- internal/db/migrations/2026_01_01_000011_create_project_labels_table.sql.up.sql
-- CREATE TABLE "project_labels" -------------------------------
CREATE TABLE IF NOT EXISTS "project_labels" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000013_create_project_links_table.sql.down.sql
-- DROP TABLE "project_links" ----------------------------------
DROP TABLE IF EXISTS "project_links";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000013_create_project_links_table.sql
-- internal/db/migrations/2026_01_01_000013_create_project_links_table.sql.up.sql
-- CREATE TABLE "project_links" --------------------------------
CREATE TABLE IF NOT EXISTS "project_links" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000014_create_project_attachments_table.sql.down.sql
-- DROP TABLE "project_attachments" ----------------------------
DROP TABLE IF EXISTS "project_attachments";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000014_create_project_attachments_table.sql
-- internal/db/migrations/2026_01_01_000014_create_project_attachments_table.sql.up.sql
-- CREATE TABLE "project_attachments" --------------------------
CREATE TABLE IF NOT EXISTS "project_attachments" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000015_create_project_favorites_table.sql.down.sql
-- DROP TABLE "project_favorites" ------------------------------
DROP TABLE IF EXISTS "project_favorites";
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000015_create_project_favorites_table.sql
-- internal/db/migrations/2026_01_01_000015_create_project_favorites_table.sql.up.sql
-- CREATE TABLE "project_favorites" ----------------------------
CREATE TABLE IF NOT EXISTS "project_favorites" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_00_000007_create_project_dependencies_table.sql.down.sql
-- DROP TABLE "project_dependencies" -----------------------------
DROP TABLE IF EXISTS "project_dependencies";
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_00_000007_create_project_dependencies_table.sql
-- internal/db/migrations/2026_01_00_000007_create_project_dependencies_table.sql.up.sql
-- CREATE TABLE "project_dependencies" -----------------------------
CREATE TABLE IF NOT EXISTS "project_dependencies" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000020_create_issues_table.sql.down.sql
-- DROP TABLE "issues" -----------------------------------------
DROP TABLE IF EXISTS "issues";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000020_create_issues_table.sql
-- internal/db/migrations/2026_01_01_000020_create_issues_table.sql.up.sql
-- CREATE TABLE "issues" ---------------------------------------
CREATE TABLE IF NOT EXISTS "issues" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000021_create_issue_labels_table.sql.down.sql
-- DROP TABLE "issue_labels" -----------------------------------
DROP TABLE IF EXISTS "issue_labels";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000021_create_issue_labels_table.sql
-- internal/db/migrations/2026_01_01_000021_create_issue_labels_table.sql.up.sql
-- CREATE TABLE "issue_labels" ---------------------------------
CREATE TABLE IF NOT EXISTS "issue_labels" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000022_create_issue_links_table.sql.down.sql
-- DROP TABLE "issue_links" ------------------------------------
DROP TABLE IF EXISTS "issue_links";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000022_create_issue_links_table.sql
-- internal/db/migrations/2026_01_01_000022_create_issue_links_table.sql.up.sql
-- CREATE TABLE "issue_links" ----------------------------------
CREATE TABLE IF NOT EXISTS "issue_links" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000023_create_issue_attachments_table.sql.down.sql
-- DROP TABLE "issue_attachments" ------------------------------
DROP TABLE IF EXISTS "issue_attachments";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000023_create_issue_attachments_table.sql
-- internal/db/migrations/2026_01_01_000023_create_issue_attachments_table.sql.up.sql
-- CREATE TABLE "issue_attachments" ----------------------------
CREATE TABLE IF NOT EXISTS "issue_attachments" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000005_create_issue_blockers_table.sql.down.sql
-- DROP TABLE "issue_blockers" ---------------------------------
DROP TABLE IF EXISTS "issue_blockers";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000005_create_issue_blockers_table.sql
-- internal/db/migrations/2026_01_01_000005_create_issue_blockers_table.sql.up.sql
-- CREATE TABLE "issue_blockers" -------------------------------
CREATE TABLE IF NOT EXISTS "issue_blockers" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000024_create_issue_comments_table.sql.down.sql
-- DROP TABLE "issue_comments" ---------------------------------
DROP TABLE IF EXISTS "issue_comments";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000024_create_issue_comments_table.sql
-- internal/db/migrations/2026_01_01_000024_create_issue_comments_table.sql.up.sql
-- CREATE TABLE "issue_comments" -------------------------------
CREATE TABLE IF NOT EXISTS "issue_comments" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000106_create_issue_comment_links_table.sql.down.sql
-- DROP TABLE "issue_comment_links" ----------------------------
DROP TABLE IF EXISTS "issue_comment_links";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000106_create_issue_comment_links_table.sql
-- internal/db/migrations/2026_01_01_000106_create_issue_comment_links_table.sql.up.sql
-- CREATE TABLE "issue_comment_links" --------------------------
CREATE TABLE IF NOT EXISTS "issue_comment_links" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_01_000107_create_issue_comment_attachments_table.sql.down.sql
-- DROP TABLE "issue_comment_attachments" --------------------------
DROP TABLE IF EXISTS "issue_comment_attachments";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_01_000107_create_issue_comment_attachments_table.sql
-- internal/db/migrations/2026_01_01_000107_create_issue_comment_attachments_table.sql.up.sql
-- CREATE TABLE "issue_comment_attachments" --------------------------
CREATE TABLE IF NOT EXISTS "issue_comment_attachments" (
@@ -0,0 +1,5 @@
-- internal/db/migrations/2026_01_02_000001_create_webhook_receipts_table.sql.down.sql
-- DROP TABLE "webhook_receipts" -------------------------------
DROP TABLE IF EXISTS "webhook_receipts";
-- -------------------------------------------------------------
@@ -1,4 +1,4 @@
-- internal/db/migrations/2026_01_02_000001_create_webhook_receipts_table.sql
-- internal/db/migrations/2026_01_02_000001_create_webhook_receipts_table.sql.up.sql
-- CREATE TABLE "webhook_receipts" -------------------------------
CREATE TABLE IF NOT EXISTS "webhook_receipts" (
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
DB_NAME="database.sqlite"
if [ -z "$1" ]; then
echo "You need to tell me up or down"
exit 1
fi
if [[ "$1" == "up" ]]; then
rm -f "$DB_NAME"
touch "$DB_NAME"
for file in migrations/*.up.sql; do
echo "Executing $file..."
sqlite3 "$DB_NAME" < "$file"
done
fi
if [[ "$1" == "down" ]]; then
for file in migrations/*.down.sql; do
echo "Executing $file..."
sqlite3 "$DB_NAME" < "$file"
done
fi
+4 -3
View File
@@ -4,11 +4,12 @@
<nav aria-label="breadcrumb">
<ol class="flex flex-wrap pt-1 mr-12 bg-transparent rounded-lg sm:mr-16">
<li class="text-sm leading-normal">
<RouterLink class="opacity-50 text-slate-700" to="/">Pages</RouterLink>
<li v-if="title !== 'Dashboard'" class="text-sm leading-normal">
<RouterLink class="opacity-50 text-slate-700" to="/dashboard">Dashboard</RouterLink>
</li>
<li
class="text-sm pl-2 capitalize leading-normal text-slate-700 before:float-left before:pr-2 before:content-['/']"
class="text-sm capitalize leading-normal text-slate-700"
:class="title !== 'Dashboard' ? 'pl-2 before:float-left before:pr-2 before:content-[\'/\']' : ''"
aria-current="page"
>
{{ title }}
-17
View File
@@ -66,23 +66,6 @@
</ul>
</div>
<div class="mx-4 mt-4">
<div class="relative flex min-w-0 flex-col items-center break-words rounded-2xl border-0 bg-white bg-clip-border shadow-none">
<div class="mb-7.5 h-28 w-full overflow-hidden rounded-xl">
<div class="bg-gradient-to-tl from-slate-600 to-slate-300 h-full w-full"></div>
</div>
<div class="-mt-14 w-3/4 text-center">
<p class="mt-0 mb-4 font-semibold leading-tight text-xs">Need help?</p>
<a
href="#"
class="inline-block w-full px-8 py-2 mb-4 font-bold text-center text-black uppercase transition-all ease-in bg-white border-0 rounded-lg shadow-soft-md bg-150 leading-pro text-xs hover:shadow-soft-2xl hover:scale-102"
>
Documentation
</a>
</div>
</div>
</div>
</aside>
</template>
+32 -32
View File
@@ -8,25 +8,7 @@
<div class="flex-auto p-4">
<div class="flex flex-row -mx-3">
<div class="flex-none w-2/3 max-w-full px-3">
<p class="mb-0 font-sans font-semibold leading-normal text-sm">Projects</p>
<h5 class="mb-0 font-bold"></h5>
</div>
<div class="px-3 text-right basis-1/3">
<div class="inline-flex w-12 h-12 text-center rounded-lg items-center justify-center bg-gradient-to-tl from-purple-700 to-pink-500 shadow-soft-2xl">
<i class="fas fa-layer-group text-white text-lg relative"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="w-full max-w-full px-3 mb-6 sm:w-1/2 sm:flex-none xl:mb-0 xl:w-1/4">
<div class="relative flex flex-col min-w-0 break-words bg-white shadow-soft-xl rounded-2xl bg-clip-border">
<div class="flex-auto p-4">
<div class="flex flex-row -mx-3">
<div class="flex-none w-2/3 max-w-full px-3">
<p class="mb-0 font-sans font-semibold leading-normal text-sm">Open Tasks</p>
<p class="mb-0 font-sans font-semibold leading-normal text-sm">Open Issues</p>
<h5 class="mb-0 font-bold"></h5>
</div>
<div class="px-3 text-right basis-1/3">
@@ -75,23 +57,29 @@
</div>
</div>
<div class="w-full max-w-full px-3 mb-6 sm:w-1/2 sm:flex-none xl:mb-0 xl:w-1/4">
<div class="relative flex flex-col min-w-0 break-words bg-white shadow-soft-xl rounded-2xl bg-clip-border">
<div class="flex-auto p-4">
<div class="flex flex-row -mx-3">
<div class="flex-none w-2/3 max-w-full px-3">
<p class="mb-0 font-sans font-semibold leading-normal text-sm">Projects</p>
<h5 class="mb-0 font-bold"></h5>
</div>
<div class="px-3 text-right basis-1/3">
<div class="inline-flex w-12 h-12 text-center rounded-lg items-center justify-center bg-gradient-to-tl from-purple-700 to-pink-500 shadow-soft-2xl">
<i class="fas fa-layer-group text-white text-lg relative"></i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="flex flex-wrap mt-6 -mx-3">
<div class="w-full max-w-full px-3 mt-0 lg:w-7/12 lg:flex-none">
<div class="relative flex flex-col min-w-0 break-words bg-white border-0 shadow-soft-xl rounded-2xl bg-clip-border">
<div class="border-black/12.5 rounded-t-2xl border-b-0 border-solid p-6 pb-0">
<h6 class="capitalize">Recent Projects</h6>
<p class="text-sm leading-normal">Your active projects</p>
</div>
<div class="flex-auto p-6 pt-4">
<p class="text-sm text-slate-500 text-center py-8">No projects yet.</p>
</div>
</div>
</div>
<div class="w-full max-w-full px-3 mt-4 lg:w-5/12 lg:flex-none lg:mt-0">
<div class="w-full max-w-full px-3 mt-4 lg:w-7/12 lg:flex-none lg:mt-0">
<div class="relative flex flex-col min-w-0 break-words bg-white border-0 shadow-soft-xl rounded-2xl bg-clip-border">
<div class="border-black/12.5 rounded-t-2xl border-b-0 border-solid p-6 pb-0">
<h6 class="capitalize">Activity</h6>
@@ -103,6 +91,18 @@
</div>
</div>
<div class="w-full max-w-full px-3 mt-0 lg:w-5/12 lg:flex-none">
<div class="relative flex flex-col min-w-0 break-words bg-white border-0 shadow-soft-xl rounded-2xl bg-clip-border">
<div class="border-black/12.5 rounded-t-2xl border-b-0 border-solid p-6 pb-0">
<h6 class="capitalize">Recent Projects</h6>
<p class="text-sm leading-normal">Your active projects</p>
</div>
<div class="flex-auto p-6 pt-4">
<p class="text-sm text-slate-500 text-center py-8">No projects yet.</p>
</div>
</div>
</div>
</div>
</AppLayout>