chore: #174 make into template

This commit is contained in:
2024-12-31 12:21:47 +01:00
parent 508aa3038b
commit 52f6d3d706
30 changed files with 89 additions and 89 deletions

View File

@@ -11,5 +11,5 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: docker build . -t me-fit-test
- run: docker rmi me-fit-test
- run: docker build . -t web-app-template-test
- run: docker rmi web-app-template-test

View File

@@ -11,8 +11,8 @@ jobs:
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: docker login git.wundenbergs.de -u tim -p ${{ secrets.DOCKER_GITEA_TOKEN }}
- run: docker build . -t git.wundenbergs.de/x/me-fit:latest -t git.wundenbergs.de/x/me-fit:$GITHUB_SHA
- run: docker push git.wundenbergs.de/x/me-fit:latest
- run: docker push git.wundenbergs.de/x/me-fit:$GITHUB_SHA
- run: docker rmi git.wundenbergs.de/x/me-fit:latest git.wundenbergs.de/x/me-fit:$GITHUB_SHA
- run: docker build . -t git.wundenbergs.de/x/web-app-template:latest -t git.wundenbergs.de/x/web-app-template:$GITHUB_SHA
- run: docker push git.wundenbergs.de/x/web-app-template:latest
- run: docker push git.wundenbergs.de/x/web-app-template:$GITHUB_SHA
- run: docker rmi git.wundenbergs.de/x/web-app-template:latest git.wundenbergs.de/x/web-app-template:$GITHUB_SHA

View File

@@ -3,11 +3,11 @@ dir: mocks/
outpkg: mocks
issue-845-fix: True
packages:
me-fit/service:
web-app-template/service:
interfaces:
Random:
Clock:
Mail:
me-fit/db:
web-app-template/db:
interfaces:
Auth:

View File

@@ -1,5 +1,5 @@
FROM golang:1.23.4@sha256:7ea4c9dcb2b97ff8ee80a67db3d44f98c8ffa0d191399197007d8459c1453041 AS builder_go
WORKDIR /me-fit
WORKDIR /web-app-template
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2
RUN go install github.com/a-h/templ/cmd/templ@latest
RUN go install github.com/vektra/mockery/v2@latest
@@ -10,11 +10,11 @@ RUN templ generate
RUN mockery --log-level warn
RUN go test ./...
RUN golangci-lint run ./...
RUN go build -o /me-fit/me-fit .
RUN go build -o /web-app-template/web-app-template .
FROM node:22.12.0@sha256:0e910f435308c36ea60b4cfd7b80208044d77a074d16b768a81901ce938a62dc AS builder_node
WORKDIR /me-fit
WORKDIR /web-app-template
COPY package.json package-lock.json ./
RUN npm clean-install
COPY . ./
@@ -22,11 +22,11 @@ RUN npm run build
FROM debian:12.8@sha256:b877a1a3fdf02469440f1768cf69c9771338a875b7add5e80c45b756c92ac20a
WORKDIR /me-fit
WORKDIR /web-app-template
RUN apt-get update && apt-get install -y ca-certificates && echo "" > .env
COPY migration ./migration
COPY --from=builder_go /me-fit/me-fit ./me-fit
COPY --from=builder_node /me-fit/static ./static
COPY --from=builder_go /web-app-template/web-app-template ./web-app-template
COPY --from=builder_node /web-app-template/static ./static
EXPOSE 8080
ENTRYPOINT ["/me-fit/me-fit"]
ENTRYPOINT ["/web-app-template/web-app-template"]

View File

@@ -1,8 +1,8 @@
package db
import (
"me-fit/log"
"me-fit/types"
"web-app-template/log"
"web-app-template/types"
"database/sql"
"errors"

View File

@@ -2,7 +2,7 @@ package db
import (
"database/sql"
"me-fit/types"
"web-app-template/types"
"testing"
"time"

View File

@@ -1,8 +1,8 @@
package db
import (
"me-fit/log"
"me-fit/types"
"web-app-template/log"
"web-app-template/types"
"database/sql"
"errors"

View File

@@ -1,8 +1,8 @@
package db
import (
"me-fit/log"
"me-fit/types"
"web-app-template/log"
"web-app-template/types"
"database/sql"
"errors"

2
go.mod
View File

@@ -1,4 +1,4 @@
module me-fit
module web-app-template
go 1.22.5

View File

@@ -1,12 +1,12 @@
package handler
import (
"me-fit/handler/middleware"
"me-fit/log"
"me-fit/service"
"me-fit/template/auth"
"me-fit/types"
"me-fit/utils"
"web-app-template/handler/middleware"
"web-app-template/log"
"web-app-template/service"
"web-app-template/template/auth"
"web-app-template/types"
"web-app-template/utils"
"errors"
"net/http"

View File

@@ -1,9 +1,9 @@
package handler
import (
"me-fit/handler/middleware"
"me-fit/service"
"me-fit/template"
"web-app-template/handler/middleware"
"web-app-template/service"
"web-app-template/template"
"net/http"

View File

@@ -4,8 +4,8 @@ import (
"context"
"net/http"
"me-fit/service"
"me-fit/types"
"web-app-template/service"
"web-app-template/types"
)
type ContextKey string

View File

@@ -5,10 +5,10 @@ import (
"net/http"
"strings"
"me-fit/log"
"me-fit/service"
"me-fit/types"
"me-fit/utils"
"web-app-template/log"
"web-app-template/service"
"web-app-template/types"
"web-app-template/utils"
)
type csrfResponseWriter struct {

View File

@@ -5,7 +5,7 @@ import (
"strconv"
"time"
"me-fit/log"
"web-app-template/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

View File

@@ -3,7 +3,7 @@ package middleware
import (
"net/http"
"me-fit/types"
"web-app-template/types"
)
func SecurityHeaders(serverSettings *types.Settings) func(http.Handler) http.Handler {

View File

@@ -1,10 +1,10 @@
package handler
import (
"me-fit/log"
"me-fit/template"
"me-fit/template/auth"
"me-fit/types"
"web-app-template/log"
"web-app-template/template"
"web-app-template/template/auth"
"web-app-template/types"
"net/http"

View File

@@ -1,10 +1,10 @@
package handler
import (
"me-fit/handler/middleware"
"me-fit/service"
"me-fit/template/workout"
"me-fit/utils"
"web-app-template/handler/middleware"
"web-app-template/service"
"web-app-template/template/workout"
"web-app-template/utils"
"net/http"
"strconv"

12
main.go
View File

@@ -1,12 +1,12 @@
package main
import (
"me-fit/db"
"me-fit/handler"
"me-fit/handler/middleware"
"me-fit/log"
"me-fit/service"
"me-fit/types"
"web-app-template/db"
"web-app-template/handler"
"web-app-template/handler/middleware"
"web-app-template/log"
"web-app-template/service"
"web-app-template/types"
"context"
"database/sql"

View File

@@ -11,8 +11,8 @@ import (
"testing"
"time"
"me-fit/service"
"me-fit/types"
"web-app-template/service"
"web-app-template/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"

4
package-lock.json generated
View File

@@ -1,11 +1,11 @@
{
"name": "me-fit",
"name": "web-app-template",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "me-fit",
"name": "web-app-template",
"version": "1.0.0",
"license": "ISC",
"devDependencies": {

View File

@@ -1,5 +1,5 @@
{
"name": "me-fit",
"name": "web-app-template",
"version": "1.0.0",
"description": "Your (almost) independent tech stack to host on a VPC.",
"main": "index.js",

View File

@@ -8,10 +8,10 @@ import (
"strings"
"time"
"me-fit/db"
"me-fit/log"
mailTemplate "me-fit/template/mail"
"me-fit/types"
"web-app-template/db"
"web-app-template/log"
mailTemplate "web-app-template/template/mail"
"web-app-template/types"
"github.com/google/uuid"
"golang.org/x/crypto/argon2"
@@ -249,7 +249,7 @@ func (service AuthImpl) SendVerificationMail(userId uuid.UUID, email string) {
return
}
service.mail.SendMail(email, "Welcome to ME-FIT", w.String())
service.mail.SendMail(email, "Welcome to web-app-template", w.String())
}
func (service AuthImpl) VerifyUserEmail(tokenStr string) error {

View File

@@ -1,9 +1,9 @@
package service
import (
"me-fit/db"
"me-fit/mocks"
"me-fit/types"
"web-app-template/db"
"web-app-template/mocks"
"web-app-template/types"
"strings"
"testing"
@@ -127,7 +127,7 @@ func TestSendVerificationMail(t *testing.T) {
mockAuthDb.EXPECT().GetTokensByUserIdAndType(userId, types.TokenTypeEmailVerify).Return(tokens, nil)
mockMail.EXPECT().SendMail(email, "Welcome to ME-FIT", mock.MatchedBy(func(message string) bool {
mockMail.EXPECT().SendMail(email, "Welcome to web-app-template", mock.MatchedBy(func(message string) bool {
return strings.Contains(message, token.Token)
})).Return()

View File

@@ -1,8 +1,8 @@
package service
import (
"me-fit/log"
"me-fit/types"
"web-app-template/log"
"web-app-template/types"
"fmt"
"net/smtp"

View File

@@ -1,8 +1,8 @@
package service
import (
"me-fit/log"
"me-fit/types"
"web-app-template/log"
"web-app-template/types"
"crypto/rand"
"encoding/base64"

View File

@@ -1,8 +1,8 @@
package service
import (
"me-fit/db"
"me-fit/types"
"web-app-template/db"
"web-app-template/types"
"errors"
"strconv"

View File

@@ -1,16 +1,16 @@
package template
templ Index() {
<div class="hero bg-base-200 h-full">
<div class="hero-content text-center">
<div class="max-w-md">
<h1 class="text-5xl font-bold">Next Level Workout Tracker</h1>
<p class="py-6">
Ever wanted to track your workouts and see your progress over time? ME-FIT is the perfect
solution for you.
</p>
<a href="/workout" class="btn btn-primary">Get Started</a>
</div>
<div class="hero bg-base-200 h-full">
<div class="hero-content text-center">
<div class="max-w-md">
<h1 class="text-5xl font-bold">Next Level Workout Tracker</h1>
<p class="py-6">
Ever wanted to track your workouts and see your progress over time? web-app-template is the perfect
solution for you.
</p>
<a href="/workout" class="btn btn-primary">Get Started</a>
</div>
</div>
</div>
}

View File

@@ -6,7 +6,7 @@ templ Layout(slot templ.Component, user templ.Component) {
<head>
<meta charset="utf-8" />
<title>ME-FIT</title>
<title>web-app-template</title>
<link rel="icon" href="/static/favicon.svg" />
<link rel="stylesheet" href="/static/css/tailwind.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -23,8 +23,8 @@ templ Layout(slot templ.Component, user templ.Component) {
<div class="h-screen flex flex-col">
<div class="flex justify-end items-center gap-2 py-1 px-2 h-12 md:gap-10 md:px-10 md:py-2 shadow">
<a href="/" class="flex-1 flex gap-2">
<img src="/static/favicon.svg" alt="ME-FIT logo" />
<span>ME-FIT</span>
<img src="/static/favicon.svg" alt="web-app-template logo" />
<span>web-app-template</span>
</a>
@user
</div>

View File

@@ -1,7 +1,7 @@
package types
import (
"me-fit/log"
"web-app-template/log"
)
type Settings struct {

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"time"
"me-fit/log"
"web-app-template/log"
)
func TriggerToast(w http.ResponseWriter, r *http.Request, class string, message string, statusCode int) {