Skip to content

Commit

Permalink
Add site creation endpoint (#215)
Browse files Browse the repository at this point in the history
* Add site creation endpoint

* Update go modules

* Update main.go

* Add site creation endpoint

* Update go modules

* Update main.go

* Handle organization's not having google oauth refresh token

* Update run_tests.yaml
  • Loading branch information
th0th authored Dec 18, 2024
1 parent be9f298 commit 4d7f08a
Show file tree
Hide file tree
Showing 25 changed files with 960 additions and 154 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
jobs:
frontend:
if: "contains(github.event.pull_request.labels.*.name, 'status: ready for review')"
if: "!contains(github.event.pull_request.labels.*.name, 'status: in progress')"
name: Run frontend tests
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
workdir: frontend

backend:
if: "contains(github.event.pull_request.labels.*.name, 'status: ready for review')"
if: "!contains(github.event.pull_request.labels.*.name, 'status: in progress')"
name: Run backend tests
runs-on: ubuntu-latest
steps:
Expand Down
11 changes: 4 additions & 7 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions backend/cmd/rest-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ func main() {
}

validationService := validation.New(validation.NewParams{
Postgres: postgres,
EnvService: envService,
Postgres: postgres,
})

emailService, err := email.New(email.NewParams{
Expand All @@ -96,7 +97,8 @@ func main() {
})

siteService := site.New(site.NewParams{
Postgres: postgres,
Postgres: postgres,
ValidationService: validationService,
})

responder := restapiresponder.New(restapiresponder.NewParams{
Expand Down Expand Up @@ -134,6 +136,7 @@ func main() {
sensitiveRateLimit := alice.New(middleware.SensitiveRateLimit(responder, limiterStore))
permissionBasicAuthenticated := alice.New(middleware.PermissionBasicAuthenticated(responder))
permissionUserAccessTokenAuthenticated := alice.New(middleware.PermissionUserAccessTokenAuthenticated(responder))
permissionWrite := alice.New(middleware.PermissionOrganizationOwner(responder))

// handlers: authentication
mux.Handle("POST /authentication/user-access-tokens", sensitiveRateLimit.Extend(permissionBasicAuthenticated).ThenFunc(authenticationHandler.CreateUserAccessToken))
Expand All @@ -153,6 +156,7 @@ func main() {
mux.HandleFunc("/{$}", rootHandler.Index())

// handlers: sites
mux.Handle("POST /sites", permissionWrite.ThenFunc(sitesHandler.Create))
mux.Handle("GET /sites", permissionUserAccessTokenAuthenticated.ThenFunc(sitesHandler.List))

httpServer := http.Server{
Expand Down
21 changes: 20 additions & 1 deletion backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,38 @@ require (
github.com/swaggo/swag v1.16.4
github.com/ulule/limiter/v3 v3.11.2
golang.org/x/crypto v0.29.0
golang.org/x/oauth2 v0.24.0
google.golang.org/api v0.206.0
gorm.io/driver/clickhouse v0.6.1
gorm.io/driver/postgres v1.5.9
gorm.io/gorm v1.25.12
)

require (
cloud.google.com/go/auth v0.10.2 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.5 // indirect
cloud.google.com/go/compute/metadata v0.5.2 // indirect
github.com/ClickHouse/ch-go v0.61.5 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.23.2 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/spec v0.20.6 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.14.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
Expand All @@ -67,14 +79,21 @@ require (
github.com/stretchr/objx v0.5.2 // indirect
github.com/swaggo/files/v2 v2.0.0 // indirect
github.com/th0th/disposableemail v0.0.2-0.20241107110532-1e027547679f // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.24.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 4d7f08a

Please sign in to comment.