diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index e2bfce7..6adff74 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -3,7 +3,8 @@ name: Release Backend service to Docker Hub and Deploy to Kubernetes on: push: paths: - - "backend/**" + - "cmd/backend/**" + - "pkg/**" - "deployment/backend/**" - ".github/workflows/backend-cd.yml" @@ -46,6 +47,6 @@ jobs: uses: docker/build-push-action@v5 with: push: true - context: "{{defaultContext}}:backend" + context: "{{defaultContext}}:cmd/backend" tags: vcscsvcscs/gheritage-backend-service:${{steps.create_image_tag.outputs.result}} platforms: linux/arm64 diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index ebee273..25ab1d4 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -2,19 +2,20 @@ name: Backend Continuous Integration on: push: paths: - - "backend/**" + - "cmd/backend/**" + - "pkg/**" jobs: lint: uses: ./.github/workflows/go_lint.yml with: - working-directory: 'backend' + working-directory: 'cmd/backend' build: needs: lint uses: ./.github/workflows/go_build.yml with: - working-directory: 'backend' + working-directory: 'cmd/backend' test: needs: build uses: ./.github/workflows/go_test.yml with: - working-directory: 'backend' \ No newline at end of file + working-directory: 'cmd/backend' \ No newline at end of file diff --git a/backend/auth.go b/backend/auth.go deleted file mode 100644 index 0246199..0000000 --- a/backend/auth.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "net/http" - - "github.com/gin-gonic/gin" - "github.com/zitadel/zitadel-go/v3/pkg/authorization/oauth" - "github.com/zitadel/zitadel-go/v3/pkg/http/middleware" -) - -func auth(mw *middleware.Interceptor[*oauth.IntrospectionContext]) gin.HandlerFunc { - return func(c *gin.Context) { - mw.RequireAuthorization()(http.HandlerFunc(authHTTPHandler(mw, c))).ServeHTTP(c.Writer, c.Request) - } -} - -func authHTTPHandler(mw *middleware.Interceptor[*oauth.IntrospectionContext], c *gin.Context) func(w http.ResponseWriter, r *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - authCtx := mw.Context(r.Context()) - c.Set("id", authCtx.UserID()) - c.Next() - } -} diff --git a/backend/dockerfile b/backend/dockerfile deleted file mode 100644 index d1ff741..0000000 --- a/backend/dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM arm64v8/golang:1.22.2-alpine as build - -WORKDIR /app - -COPY . . - -RUN GOOS=linux GOARCH=arm64 go build -o backend - -RUN apk update && apk add ca-certificates && update-ca-certificates - -FROM arm64v8/busybox:1.36.1 - -COPY --from=build /etc/ssl/certs /etc/ssl/certs -COPY --from=build /app/backend /app/ - -CMD [ "/app/backend" ] \ No newline at end of file diff --git a/backend/go.mod b/backend/go.mod deleted file mode 100644 index ec0493c..0000000 --- a/backend/go.mod +++ /dev/null @@ -1,50 +0,0 @@ -module github.com/vcscsvcscs/GenerationsHeritage/backend - -go 1.22.2 - -require ( - github.com/gin-contrib/cors v1.7.1 - github.com/gin-gonic/gin v1.9.1 - github.com/google/uuid v1.6.0 - github.com/neo4j/neo4j-go-driver/v5 v5.19.0 - github.com/vcscsvcscs/GenerationsHeritage/utilities v0.0.0-20240414091827-ffde94d457cb - github.com/zitadel/zitadel-go/v3 v3.0.0-next.2 - golang.org/x/net v0.23.0 -) - -require ( - github.com/bytedance/sonic v1.11.3 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect - github.com/chenzhuoyu/iasm v0.9.1 // indirect - github.com/gabriel-vasile/mimetype v1.4.3 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-jose/go-jose/v3 v3.0.1 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.19.0 // indirect - github.com/goccy/go-json v0.10.2 // indirect - github.com/gorilla/securecookie v1.1.2 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.7 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/leodido/go-urn v1.4.0 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/muhlemmer/gu v0.3.1 // indirect - github.com/pelletier/go-toml/v2 v2.2.0 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.12 // indirect - github.com/zitadel/logging v0.5.0 // indirect - github.com/zitadel/oidc/v3 v3.5.1 // indirect - github.com/zitadel/schema v1.3.0 // indirect - golang.org/x/arch v0.7.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 // indirect - golang.org/x/oauth2 v0.19.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/backend/go.sum b/backend/go.sum deleted file mode 100644 index 05c39e7..0000000 --- a/backend/go.sum +++ /dev/null @@ -1,158 +0,0 @@ -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM= -github.com/bytedance/sonic v1.11.3 h1:jRN+yEjakWh8aK5FzrciUHG8OFXK+4/KrAX/ysEtHAA= -github.com/bytedance/sonic v1.11.3/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= -github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0= -github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA= -github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog= -github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0= -github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= -github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= -github.com/gin-contrib/cors v1.7.1 h1:s9SIppU/rk8enVvkzwiC2VK3UZ/0NNGsWfUKvV55rqs= -github.com/gin-contrib/cors v1.7.1/go.mod h1:n/Zj7B4xyrgk/cX1WCX2dkzFfaNm/xJb6oIUk7WTtps= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= -github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk= -github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= -github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA= -github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn0+wvQ3bZ8b/AU4= -github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= -github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= -github.com/jeremija/gosubmit v0.2.7 h1:At0OhGCFGPXyjPYAsCchoBUhE099pcBXmsb4iZqROIc= -github.com/jeremija/gosubmit v0.2.7/go.mod h1:Ui+HS073lCFREXBbdfrJzMB57OI/bdxTiLtrDHHhFPI= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= -github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/muhlemmer/gu v0.3.1 h1:7EAqmFrW7n3hETvuAdmFmn4hS8W+z3LgKtrnow+YzNM= -github.com/muhlemmer/gu v0.3.1/go.mod h1:YHtHR+gxM+bKEIIs7Hmi9sPT3ZDUvTN/i88wQpZkrdM= -github.com/muhlemmer/httpforwarded v0.1.0 h1:x4DLrzXdliq8mprgUMR0olDvHGkou5BJsK/vWUetyzY= -github.com/muhlemmer/httpforwarded v0.1.0/go.mod h1:yo9czKedo2pdZhoXe+yDkGVbU0TJ0q9oQ90BVoDEtw0= -github.com/neo4j/neo4j-go-driver/v5 v5.19.0 h1:v2cB19fZQYz1xmj6EZXofFHD/+Tj16hH/OOp39uNN1I= -github.com/neo4j/neo4j-go-driver/v5 v5.19.0/go.mod h1:Vff8OwT7QpLm7L2yYr85XNWe9Rbqlbeb9asNXJTHO4k= -github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo= -github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= -github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= -github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/vcscsvcscs/GenerationsHeritage/utilities v0.0.0-20240414091827-ffde94d457cb h1:fU736we2gQQRMOWP/su7sCiUFmrXTKBN0s8LG5k7bOE= -github.com/vcscsvcscs/GenerationsHeritage/utilities v0.0.0-20240414091827-ffde94d457cb/go.mod h1:aQlmG6BiGFmOFxzAkWTJDzm1EzdCJ4OEETXTUkWJaLk= -github.com/zitadel/logging v0.5.0 h1:Kunouvqse/efXy4UDvFw5s3vP+Z4AlHo3y8wF7stXHA= -github.com/zitadel/logging v0.5.0/go.mod h1:IzP5fzwFhzzyxHkSmfF8dsyqFsQRJLLcQmwhIBzlGsE= -github.com/zitadel/oidc/v3 v3.5.1 h1:7gyrxRNqX5eZYai2KhzPj8MhBZ7I3YpviQeX1Lp4j4U= -github.com/zitadel/oidc/v3 v3.5.1/go.mod h1:R8sF5DPR98QQnOoyySsaNqI4NcF/VFMkf/XoYiBUuXQ= -github.com/zitadel/schema v1.3.0 h1:kQ9W9tvIwZICCKWcMvCEweXET1OcOyGEuFbHs4o5kg0= -github.com/zitadel/schema v1.3.0/go.mod h1:NptN6mkBDFvERUCvZHlvWmmME+gmZ44xzwRXwhzsbtc= -github.com/zitadel/zitadel-go/v3 v3.0.0-next.2 h1:w0lnLvijwQwkrUEA74loenNR9udRAaq6rccjlMSA+4U= -github.com/zitadel/zitadel-go/v3 v3.0.0-next.2/go.mod h1:SY9IZuDw/766mwEobCX7JNwXawIQxVseo679JG1U0c0= -go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= -go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= -go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= -go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= -go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= -go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc= -golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE= -golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= -golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/backend/main.go b/backend/main.go deleted file mode 100644 index bec874e..0000000 --- a/backend/main.go +++ /dev/null @@ -1,107 +0,0 @@ -package main - -import ( - "context" - "flag" - "log" - "os" - "os/signal" - "syscall" - "time" - - "github.com/gin-contrib/cors" - "github.com/gin-gonic/gin" - "github.com/vcscsvcscs/GenerationsHeritage/backend/handlers" - "github.com/vcscsvcscs/GenerationsHeritage/backend/memgraph" - "github.com/vcscsvcscs/GenerationsHeritage/utilities" - "github.com/vcscsvcscs/GenerationsHeritage/utilities/gin_liveness" - "github.com/zitadel/zitadel-go/v3/pkg/authorization" - "github.com/zitadel/zitadel-go/v3/pkg/authorization/oauth" - "github.com/zitadel/zitadel-go/v3/pkg/http/middleware" - "github.com/zitadel/zitadel-go/v3/pkg/zitadel" -) - -var ( - cert = flag.String("cert", "/etc/gh-backend/ssl/tls.crt", "Specify the path of TLS cert") - key = flag.String("key", "/etc/gh-backend/ssl/tls.key", "Specify the path of TLS key") - httpsPort = flag.String("https", ":443", "Specify port for http secure hosting(example for format :443)") - httpPort = flag.String("http", ":80", "Specify port for http hosting(example for format :80)") - zitadelAccessKey = flag.String("zitadel-access-key", "/etc/gh-backend/zitadel/api-key.json", "Specify the path of Zitadel access key") - zitadelURI = flag.String("zitadel-uri", "zitadel.varghacsongor.hu", "Specify the Zitadel URI") - memgraphURI = flag.String("memgraph", "bolt+ssc://memgraph:7687", "Specify the Memgraph database URI") - memgraphUser = flag.String("memgraph-user", "", "Specify the Memgraph database user") - memgraphPass = flag.String("memgraph-pass", "", "Specify the Memgraph database password") - release = flag.Bool("release", false, "Set true to release build") - logToFile = flag.Bool("log-to-file", false, "Set true to log to file") - logToFileAndStd = flag.Bool("log-to-file-and-std", false, "Set true to log to file and std") - requestTimeout = time.Duration(*flag.Int("request-timeout", 20, "Set request timeout in seconds")) -) - -func main() { - flag.Parse() - if *release { - gin.SetMode(gin.ReleaseMode) - } - - utilities.SetupLogger(*logToFileAndStd, *logToFile) - - hc := gin_liveness.New() - - memgraphDriver := memgraph.InitDatabase(*memgraphURI, *memgraphUser, *memgraphPass) - - router := gin.Default() - router.Use(cors.New(cors.Config{ - AllowOrigins: []string{"http://localhost:5173", "http://localhost", "https://heritagebackend.varghacsongor.hu", "https://feature-add-frontend.generationsheritage.pages.dev/", "https://csalad.varghacsongor.hu/"}, - AllowCredentials: true, - AllowHeaders: []string{"Authorization", "id", "Content-Type"}, - MaxAge: 12 * time.Hour, - })) - router.Use(gin.Recovery()) - - ctx := context.Background() - - // Initiate the authorization by providing a zitadel configuration and a verifier. - // This example will use OAuth2 Introspection for this, therefore you will also need to provide the downloaded api key.json - authZ, err := authorization.New(ctx, zitadel.New(*zitadelURI), oauth.DefaultAuthorization(*zitadelAccessKey)) - if err != nil { - log.Println("zitadel sdk could not initialize", "error", err) - os.Exit(1) - } - - // Initialize the HTTP middleware by providing the authorization - mw := middleware.New(authZ) - - router.Use(auth(mw)) - router.GET("/health", hc.HealthCheckHandler()) - router.GET("/person", handlers.ViewPerson(memgraphDriver)) - router.POST("/person", handlers.CreatePerson(memgraphDriver)) - router.DELETE("/person", handlers.DeletePerson(memgraphDriver)) - router.PUT("/person", handlers.UpdatePerson(memgraphDriver)) - router.POST("/relationship", handlers.CreateRelationship(memgraphDriver)) - router.DELETE("/relationship", handlers.DeleteRelationship(memgraphDriver)) - router.PUT("/relationship", handlers.VerifyRelationship(memgraphDriver)) - router.POST("/createRelationshipAndPerson", handlers.CreateRelationshipAndPerson(memgraphDriver)) - router.GET("/familyTree", handlers.ViewFamiliyTree(memgraphDriver)) - - server := utilities.SetupHttpsServer(router, *cert, *key, *httpsPort, *httpPort, requestTimeout) - - // Wait for interrupt signal to gracefully shutdown the server with some time to finish requests. - quit := make(chan os.Signal, 1) - // kill (no param) default send syscall.SIGTERM - // kill -2 is syscall.SIGINT - // kill -9 is syscall.SIGKILL but can't be caught, so don't need to add it - signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) - <-quit - log.Println("Shutting down server...") - - // The context is used to inform the server it has some seconds to finish - // the request it is currently handling - ctx, cancel := context.WithTimeout(context.Background(), requestTimeout*time.Second) - defer cancel() - - if err := server.Shutdown(ctx); err != nil { - log.Fatal("Server forced to shutdown:", err) - } - - log.Println("Server exiting") -} diff --git a/backend/handlers/createPerson.go b/cmd/backend/handlers/createPerson.go similarity index 95% rename from backend/handlers/createPerson.go rename to cmd/backend/handlers/createPerson.go index 579564f..9481b9b 100644 --- a/backend/handlers/createPerson.go +++ b/cmd/backend/handlers/createPerson.go @@ -7,7 +7,7 @@ import ( "github.com/gin-gonic/gin" "github.com/neo4j/neo4j-go-driver/v5/neo4j" - "github.com/vcscsvcscs/GenerationsHeritage/backend/memgraph" + "github.com/vcscsvcscs/GenerationsHeritage/pkg/memgraph" ) func CreatePerson(driver neo4j.DriverWithContext) gin.HandlerFunc { diff --git a/backend/handlers/createRelationship.go b/cmd/backend/handlers/createRelationship.go similarity index 92% rename from backend/handlers/createRelationship.go rename to cmd/backend/handlers/createRelationship.go index 71b28eb..c80c783 100644 --- a/backend/handlers/createRelationship.go +++ b/cmd/backend/handlers/createRelationship.go @@ -6,7 +6,7 @@ import ( "github.com/gin-gonic/gin" "github.com/neo4j/neo4j-go-driver/v5/neo4j" - "github.com/vcscsvcscs/GenerationsHeritage/backend/memgraph" + "github.com/vcscsvcscs/GenerationsHeritage/pkg/memgraph" ) func CreateRelationship(driver neo4j.DriverWithContext) gin.HandlerFunc { diff --git a/backend/handlers/create_relationship_and_person.go b/cmd/backend/handlers/create_relationship_and_person.go similarity index 92% rename from backend/handlers/create_relationship_and_person.go rename to cmd/backend/handlers/create_relationship_and_person.go index 7747ee3..fbc570c 100644 --- a/backend/handlers/create_relationship_and_person.go +++ b/cmd/backend/handlers/create_relationship_and_person.go @@ -6,7 +6,7 @@ import ( "github.com/gin-gonic/gin" "github.com/neo4j/neo4j-go-driver/v5/neo4j" - "github.com/vcscsvcscs/GenerationsHeritage/backend/memgraph" + "github.com/vcscsvcscs/GenerationsHeritage/pkg/memgraph" ) func CreateRelationshipAndPerson(driver neo4j.DriverWithContext) gin.HandlerFunc { diff --git a/backend/handlers/deletePerson.go b/cmd/backend/handlers/deletePerson.go similarity index 95% rename from backend/handlers/deletePerson.go rename to cmd/backend/handlers/deletePerson.go index 48becd0..df9ef99 100644 --- a/backend/handlers/deletePerson.go +++ b/cmd/backend/handlers/deletePerson.go @@ -7,7 +7,7 @@ import ( "github.com/gin-gonic/gin" "github.com/neo4j/neo4j-go-driver/v5/neo4j" - "github.com/vcscsvcscs/GenerationsHeritage/backend/memgraph" + "github.com/vcscsvcscs/GenerationsHeritage/pkg/memgraph" ) func DeletePerson(driver neo4j.DriverWithContext) gin.HandlerFunc { diff --git a/backend/handlers/deleteRelationship.go b/cmd/backend/handlers/deleteRelationship.go similarity index 92% rename from backend/handlers/deleteRelationship.go rename to cmd/backend/handlers/deleteRelationship.go index 160019a..e1cf576 100644 --- a/backend/handlers/deleteRelationship.go +++ b/cmd/backend/handlers/deleteRelationship.go @@ -6,7 +6,7 @@ import ( "github.com/gin-gonic/gin" "github.com/neo4j/neo4j-go-driver/v5/neo4j" - "github.com/vcscsvcscs/GenerationsHeritage/backend/memgraph" + "github.com/vcscsvcscs/GenerationsHeritage/pkg/memgraph" ) func DeleteRelationship(driver neo4j.DriverWithContext) gin.HandlerFunc { diff --git a/backend/handlers/updatePerson.go b/cmd/backend/handlers/updatePerson.go similarity index 95% rename from backend/handlers/updatePerson.go rename to cmd/backend/handlers/updatePerson.go index ce094cb..f413643 100644 --- a/backend/handlers/updatePerson.go +++ b/cmd/backend/handlers/updatePerson.go @@ -7,7 +7,7 @@ import ( "github.com/gin-gonic/gin" "github.com/neo4j/neo4j-go-driver/v5/neo4j" - "github.com/vcscsvcscs/GenerationsHeritage/backend/memgraph" + "github.com/vcscsvcscs/GenerationsHeritage/pkg/memgraph" ) func UpdatePerson(driver neo4j.DriverWithContext) gin.HandlerFunc { diff --git a/backend/handlers/verifyRelationship.go b/cmd/backend/handlers/verifyRelationship.go similarity index 92% rename from backend/handlers/verifyRelationship.go rename to cmd/backend/handlers/verifyRelationship.go index d347d80..5b3e9f9 100644 --- a/backend/handlers/verifyRelationship.go +++ b/cmd/backend/handlers/verifyRelationship.go @@ -6,7 +6,7 @@ import ( "github.com/gin-gonic/gin" "github.com/neo4j/neo4j-go-driver/v5/neo4j" - "github.com/vcscsvcscs/GenerationsHeritage/backend/memgraph" + "github.com/vcscsvcscs/GenerationsHeritage/pkg/memgraph" ) func VerifyRelationship(driver neo4j.DriverWithContext) gin.HandlerFunc { diff --git a/backend/handlers/viewFamilyTree.go b/cmd/backend/handlers/viewFamilyTree.go similarity index 100% rename from backend/handlers/viewFamilyTree.go rename to cmd/backend/handlers/viewFamilyTree.go diff --git a/backend/handlers/viewPerson.go b/cmd/backend/handlers/viewPerson.go similarity index 100% rename from backend/handlers/viewPerson.go rename to cmd/backend/handlers/viewPerson.go diff --git a/backend/memgraph/create_person.go b/pkg/memgraph/create_person.go similarity index 100% rename from backend/memgraph/create_person.go rename to pkg/memgraph/create_person.go diff --git a/backend/memgraph/create_relationship.go b/pkg/memgraph/create_relationship.go similarity index 100% rename from backend/memgraph/create_relationship.go rename to pkg/memgraph/create_relationship.go diff --git a/backend/memgraph/create_relationship_and_person.go b/pkg/memgraph/create_relationship_and_person.go similarity index 100% rename from backend/memgraph/create_relationship_and_person.go rename to pkg/memgraph/create_relationship_and_person.go diff --git a/backend/memgraph/create_schema.go b/pkg/memgraph/create_schema.go similarity index 100% rename from backend/memgraph/create_schema.go rename to pkg/memgraph/create_schema.go diff --git a/backend/memgraph/cypher_verify_string.go b/pkg/memgraph/cypher_verify_string.go similarity index 100% rename from backend/memgraph/cypher_verify_string.go rename to pkg/memgraph/cypher_verify_string.go diff --git a/backend/memgraph/delete_person.go b/pkg/memgraph/delete_person.go similarity index 100% rename from backend/memgraph/delete_person.go rename to pkg/memgraph/delete_person.go diff --git a/backend/memgraph/delete_relationship.go b/pkg/memgraph/delete_relationship.go similarity index 100% rename from backend/memgraph/delete_relationship.go rename to pkg/memgraph/delete_relationship.go diff --git a/backend/memgraph/init_database.go b/pkg/memgraph/init_database.go similarity index 100% rename from backend/memgraph/init_database.go rename to pkg/memgraph/init_database.go diff --git a/backend/memgraph/model.go b/pkg/memgraph/model.go similarity index 100% rename from backend/memgraph/model.go rename to pkg/memgraph/model.go diff --git a/backend/memgraph/model_test.go b/pkg/memgraph/model_test.go similarity index 100% rename from backend/memgraph/model_test.go rename to pkg/memgraph/model_test.go diff --git a/backend/memgraph/update_person.go b/pkg/memgraph/update_person.go similarity index 100% rename from backend/memgraph/update_person.go rename to pkg/memgraph/update_person.go diff --git a/backend/memgraph/verify_relationship.go b/pkg/memgraph/verify_relationship.go similarity index 100% rename from backend/memgraph/verify_relationship.go rename to pkg/memgraph/verify_relationship.go