Skip to content

Commit

Permalink
Merge pull request #13 from maxfelker/remove-dupe-account-route
Browse files Browse the repository at this point in the history
Remove dupe account route and namespace clean up
  • Loading branch information
maxfelker authored Jan 20, 2024
2 parents fe2f3c2 + d2d49d4 commit 0ed1f11
Show file tree
Hide file tree
Showing 30 changed files with 94 additions and 165 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/mw-felker/terra-major-api
module github.com/maxfelker/terra-major-api

go 1.20

Expand Down
25 changes: 12 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import (

"github.com/gorilla/handlers"

accounts "github.com/mw-felker/terra-major-api/pkg/accounts/handlers"
accountModels "github.com/mw-felker/terra-major-api/pkg/accounts/models"
auth "github.com/mw-felker/terra-major-api/pkg/auth/handlers"
characters "github.com/mw-felker/terra-major-api/pkg/characters/handlers"
characterModels "github.com/mw-felker/terra-major-api/pkg/characters/models"
core "github.com/mw-felker/terra-major-api/pkg/core"
sandboxes "github.com/mw-felker/terra-major-api/pkg/sandboxes/handlers"
sandboxModels "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
terrains "github.com/mw-felker/terra-major-api/pkg/terrains/handlers"
terrainModels "github.com/mw-felker/terra-major-api/pkg/terrains/models"
utils "github.com/mw-felker/terra-major-api/pkg/utils"
accounts "github.com/maxfelker/terra-major-api/pkg/accounts/handlers"
accountModels "github.com/maxfelker/terra-major-api/pkg/accounts/models"
auth "github.com/maxfelker/terra-major-api/pkg/auth/handlers"
characters "github.com/maxfelker/terra-major-api/pkg/characters/handlers"
characterModels "github.com/maxfelker/terra-major-api/pkg/characters/models"
core "github.com/maxfelker/terra-major-api/pkg/core"
sandboxes "github.com/maxfelker/terra-major-api/pkg/sandboxes/handlers"
sandboxModels "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
terrains "github.com/maxfelker/terra-major-api/pkg/terrains/handlers"
terrainModels "github.com/maxfelker/terra-major-api/pkg/terrains/models"
utils "github.com/maxfelker/terra-major-api/pkg/utils"
)

func seedDb(app *core.App) {
Expand All @@ -37,8 +37,7 @@ func main() {
app.Router.HandleFunc("/login", accounts.Login(app)).Methods("POST")
app.Router.HandleFunc("/tokens", auth.CreateUnityClientToken(app)).Methods("POST")

// User-centric (me) routes
app.Router.HandleFunc("/signup", accounts.CreateMyAccount(app)).Methods("POST")
// User-centric (me/my) routes
app.Router.HandleFunc("/me", accounts.GetMyAccount(app)).Methods("GET")
app.Router.HandleFunc("/my/password", accounts.UpdatePassword(app)).Methods("PATCH")
app.Router.HandleFunc("/my/sandboxes", sandboxes.GetMySandboxes(app)).Methods("GET")
Expand Down
18 changes: 8 additions & 10 deletions pkg/accounts/handlers/CreateAccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"regexp"
"strings"

models "github.com/mw-felker/terra-major-api/pkg/accounts/models"
"github.com/mw-felker/terra-major-api/pkg/core"
sandboxModels "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
terrains "github.com/mw-felker/terra-major-api/pkg/terrains"
"github.com/mw-felker/terra-major-api/pkg/utils"
models "github.com/maxfelker/terra-major-api/pkg/accounts/models"
authClient "github.com/maxfelker/terra-major-api/pkg/auth/client"
"github.com/maxfelker/terra-major-api/pkg/core"
sandboxModels "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
terrains "github.com/maxfelker/terra-major-api/pkg/terrains"
"github.com/maxfelker/terra-major-api/pkg/utils"
)

func validatePasswordRequirements(password string) bool {
Expand Down Expand Up @@ -83,11 +84,8 @@ func CreateAccount(app *core.App) http.HandlerFunc {
return
}

var accountResponse models.AccountResponse
accountResponse.BaseAccount = newAccount.BaseAccount
accountResponse.Sandbox = newSandbox

response, e := json.Marshal(accountResponse)
token := authClient.GenerateToken(newAccount.ID, newSandbox.ID, "")
response, e := json.Marshal(authClient.TokenResponse{Token: token})
if e != nil {
utils.ReturnError(writer, e.Error(), http.StatusInternalServerError)
return
Expand Down
68 changes: 0 additions & 68 deletions pkg/accounts/handlers/CreateMyAccount.go

This file was deleted.

6 changes: 3 additions & 3 deletions pkg/accounts/handlers/GetAccountById.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"net/http"

"github.com/gorilla/mux"
models "github.com/mw-felker/terra-major-api/pkg/accounts/models"
"github.com/mw-felker/terra-major-api/pkg/core"
utils "github.com/mw-felker/terra-major-api/pkg/utils"
models "github.com/maxfelker/terra-major-api/pkg/accounts/models"
"github.com/maxfelker/terra-major-api/pkg/core"
utils "github.com/maxfelker/terra-major-api/pkg/utils"
"gorm.io/gorm"
)

Expand Down
10 changes: 5 additions & 5 deletions pkg/accounts/handlers/GetMyAccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"errors"
"net/http"

models "github.com/mw-felker/terra-major-api/pkg/accounts/models"
authClient "github.com/mw-felker/terra-major-api/pkg/auth/client"
"github.com/mw-felker/terra-major-api/pkg/core"
sandboxModels "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
utils "github.com/mw-felker/terra-major-api/pkg/utils"
models "github.com/maxfelker/terra-major-api/pkg/accounts/models"
authClient "github.com/maxfelker/terra-major-api/pkg/auth/client"
"github.com/maxfelker/terra-major-api/pkg/core"
sandboxModels "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
utils "github.com/maxfelker/terra-major-api/pkg/utils"
"gorm.io/gorm"
)

Expand Down
10 changes: 5 additions & 5 deletions pkg/accounts/handlers/Login.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"net/mail"
"strings"

models "github.com/mw-felker/terra-major-api/pkg/accounts/models"
authClient "github.com/mw-felker/terra-major-api/pkg/auth/client"
"github.com/mw-felker/terra-major-api/pkg/core"
sandboxModels "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
"github.com/mw-felker/terra-major-api/pkg/utils"
models "github.com/maxfelker/terra-major-api/pkg/accounts/models"
authClient "github.com/maxfelker/terra-major-api/pkg/auth/client"
"github.com/maxfelker/terra-major-api/pkg/core"
sandboxModels "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
"github.com/maxfelker/terra-major-api/pkg/utils"
"golang.org/x/crypto/bcrypt"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/accounts/handlers/UpdateAccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"strings"

"github.com/gorilla/mux"
models "github.com/mw-felker/terra-major-api/pkg/accounts/models"
"github.com/mw-felker/terra-major-api/pkg/core"
utils "github.com/mw-felker/terra-major-api/pkg/utils"
models "github.com/maxfelker/terra-major-api/pkg/accounts/models"
"github.com/maxfelker/terra-major-api/pkg/core"
utils "github.com/maxfelker/terra-major-api/pkg/utils"
"gorm.io/gorm"
)

Expand Down
8 changes: 4 additions & 4 deletions pkg/accounts/handlers/UpdatePassword.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"encoding/json"
"net/http"

models "github.com/mw-felker/terra-major-api/pkg/accounts/models"
authClient "github.com/mw-felker/terra-major-api/pkg/auth/client"
"github.com/mw-felker/terra-major-api/pkg/core"
utils "github.com/mw-felker/terra-major-api/pkg/utils"
models "github.com/maxfelker/terra-major-api/pkg/accounts/models"
authClient "github.com/maxfelker/terra-major-api/pkg/auth/client"
"github.com/maxfelker/terra-major-api/pkg/core"
utils "github.com/maxfelker/terra-major-api/pkg/utils"
"golang.org/x/crypto/bcrypt"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/accounts/models/Account.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/google/uuid"
sandboxModels "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
sandboxModels "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
"golang.org/x/crypto/bcrypt"
"gorm.io/gorm"
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/auth/handlers/CreateUnityClientToken.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"errors"
"net/http"

authClient "github.com/mw-felker/terra-major-api/pkg/auth/client"
characters "github.com/mw-felker/terra-major-api/pkg/characters/models"
"github.com/mw-felker/terra-major-api/pkg/core"
"github.com/mw-felker/terra-major-api/pkg/utils"
authClient "github.com/maxfelker/terra-major-api/pkg/auth/client"
characters "github.com/maxfelker/terra-major-api/pkg/characters/models"
"github.com/maxfelker/terra-major-api/pkg/core"
"github.com/maxfelker/terra-major-api/pkg/utils"
"gorm.io/gorm"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/characters/handlers/ArchiveCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"

"github.com/gorilla/mux"
models "github.com/mw-felker/terra-major-api/pkg/characters/models"
"github.com/mw-felker/terra-major-api/pkg/core"
models "github.com/maxfelker/terra-major-api/pkg/characters/models"
"github.com/maxfelker/terra-major-api/pkg/core"
"gorm.io/gorm"
)

Expand Down
10 changes: 5 additions & 5 deletions pkg/characters/handlers/CreateCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"encoding/json"
"net/http"

accounts "github.com/mw-felker/terra-major-api/pkg/accounts/models"
authClient "github.com/mw-felker/terra-major-api/pkg/auth/client"
characters "github.com/mw-felker/terra-major-api/pkg/characters/models"
"github.com/mw-felker/terra-major-api/pkg/core"
utils "github.com/mw-felker/terra-major-api/pkg/utils"
accounts "github.com/maxfelker/terra-major-api/pkg/accounts/models"
authClient "github.com/maxfelker/terra-major-api/pkg/auth/client"
characters "github.com/maxfelker/terra-major-api/pkg/characters/models"
"github.com/maxfelker/terra-major-api/pkg/core"
utils "github.com/maxfelker/terra-major-api/pkg/utils"
)

func CreateCharacter(app *core.App) http.HandlerFunc {
Expand Down
4 changes: 2 additions & 2 deletions pkg/characters/handlers/GetCharacterById.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"net/http"

"github.com/gorilla/mux"
models "github.com/mw-felker/terra-major-api/pkg/characters/models"
"github.com/mw-felker/terra-major-api/pkg/core"
models "github.com/maxfelker/terra-major-api/pkg/characters/models"
"github.com/maxfelker/terra-major-api/pkg/core"
"gorm.io/gorm"
)

Expand Down
8 changes: 4 additions & 4 deletions pkg/characters/handlers/GetMyCharacters.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"encoding/json"
"net/http"

authClient "github.com/mw-felker/terra-major-api/pkg/auth/client"
models "github.com/mw-felker/terra-major-api/pkg/characters/models"
core "github.com/mw-felker/terra-major-api/pkg/core"
utils "github.com/mw-felker/terra-major-api/pkg/utils"
authClient "github.com/maxfelker/terra-major-api/pkg/auth/client"
models "github.com/maxfelker/terra-major-api/pkg/characters/models"
core "github.com/maxfelker/terra-major-api/pkg/core"
utils "github.com/maxfelker/terra-major-api/pkg/utils"
)

func GetMyCharacters(app *core.App) http.HandlerFunc {
Expand Down
4 changes: 2 additions & 2 deletions pkg/characters/handlers/UpdateCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net/http"

"github.com/gorilla/mux"
models "github.com/mw-felker/terra-major-api/pkg/characters/models"
"github.com/mw-felker/terra-major-api/pkg/core"
models "github.com/maxfelker/terra-major-api/pkg/characters/models"
"github.com/maxfelker/terra-major-api/pkg/core"
"gorm.io/gorm"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/core/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos"
"github.com/gorilla/mux"
"github.com/mw-felker/terra-major-api/pkg/utils"
"github.com/maxfelker/terra-major-api/pkg/utils"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
Expand Down
4 changes: 2 additions & 2 deletions pkg/sandboxes/handlers/ArchiveInstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net/http"

"github.com/gorilla/mux"
"github.com/mw-felker/terra-major-api/pkg/core"
models "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
"github.com/maxfelker/terra-major-api/pkg/core"
models "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
"gorm.io/gorm"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/sandboxes/handlers/ArchiveSandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net/http"

"github.com/gorilla/mux"
"github.com/mw-felker/terra-major-api/pkg/core"
models "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
"github.com/maxfelker/terra-major-api/pkg/core"
models "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
"gorm.io/gorm"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/sandboxes/handlers/CreateInstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"

"github.com/gorilla/mux"
"github.com/mw-felker/terra-major-api/pkg/core"
models "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
"github.com/maxfelker/terra-major-api/pkg/core"
models "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
)

func CreateInstance(app *core.App) http.HandlerFunc {
Expand Down
10 changes: 5 additions & 5 deletions pkg/sandboxes/handlers/CreateSandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"net/http"
"strings"

authClient "github.com/mw-felker/terra-major-api/pkg/auth/client"
"github.com/mw-felker/terra-major-api/pkg/core"
models "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
"github.com/mw-felker/terra-major-api/pkg/terrains"
utils "github.com/mw-felker/terra-major-api/pkg/utils"
authClient "github.com/maxfelker/terra-major-api/pkg/auth/client"
"github.com/maxfelker/terra-major-api/pkg/core"
models "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
"github.com/maxfelker/terra-major-api/pkg/terrains"
utils "github.com/maxfelker/terra-major-api/pkg/utils"
)

func CreateSandbox(app *core.App) http.HandlerFunc {
Expand Down
4 changes: 2 additions & 2 deletions pkg/sandboxes/handlers/GetInstancesById.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"net/http"

"github.com/gorilla/mux"
"github.com/mw-felker/terra-major-api/pkg/core"
models "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
"github.com/maxfelker/terra-major-api/pkg/core"
models "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
"gorm.io/gorm"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/sandboxes/handlers/GetInstancesBySandboxId.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"net/http"

"github.com/gorilla/mux"
"github.com/mw-felker/terra-major-api/pkg/core"
models "github.com/mw-felker/terra-major-api/pkg/sandboxes/models"
"github.com/maxfelker/terra-major-api/pkg/core"
models "github.com/maxfelker/terra-major-api/pkg/sandboxes/models"
"gorm.io/gorm"
)

Expand Down
Loading

0 comments on commit 0ed1f11

Please sign in to comment.