diff --git a/main.go b/main.go index 30c6468..3a597a8 100644 --- a/main.go +++ b/main.go @@ -53,6 +53,7 @@ func main() { func Routes() *chi.Mux { router := chi.NewRouter() // enable cors testing + // LOCK THIS DOWN FOR PRODUCTION cors := cors.New(cors.Options{ AllowedOrigins: []string{"*"}, }) diff --git a/packages/users/users.go b/packages/users/users.go index bc53a0a..581ae46 100644 --- a/packages/users/users.go +++ b/packages/users/users.go @@ -18,7 +18,7 @@ var ( type User struct { Username string `json:"username",db:"username"` Email string `json:"email",db:"email"` - Country string `json:"country",db:"country"` + Country string `json:"location",db:"location"` Bio string `json:"bio",db:"bio"` } @@ -28,7 +28,7 @@ func Init() { (id SERIAL PRIMARY KEY, username text REFERENCES users (username), email text, - country text, + location text, bio text)` DB.Exec(dbCreateStatement) } @@ -46,7 +46,7 @@ func Routes() *chi.Mux { func getUser(w http.ResponseWriter, r *http.Request) { username := chi.URLParam(r, "username") - result := DB.QueryRow("SELECT username, email, country, bio FROM user_profiles WHERE username=$1", username) + result := DB.QueryRow("SELECT username, email, location, bio FROM user_profiles WHERE username=$1", username) user := User{} err := result.Scan(&user.Username, &user.Email, &user.Country, &user.Bio) fmt.Println(err) @@ -76,7 +76,7 @@ func updateUser(w http.ResponseWriter, r *http.Request) { UPDATE user_profiles SET username = $1, email = $2, - country = $3, + location = $3, bio = $4 WHERE username = $5` _, err = DB.Exec(updateProfileStatement, user.Username, user.Email, user.Country, user.Bio, username) @@ -86,7 +86,7 @@ func updateUser(w http.ResponseWriter, r *http.Request) { func CreateProfile(username string, email string) { blankProfileStatement := ` - INSERT INTO user_profiles (username, email, country, bio) + INSERT INTO user_profiles (username, email, location, bio) VALUES ($1, $2, $3, $4)` DB.Exec(blankProfileStatement, username, email, "", "") }