Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/frontend vite build #341

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b6d0f3d
add test for HandleHTTPError
j4qfrost Aug 26, 2024
d123995
more verbose http codes
j4qfrost Aug 26, 2024
d56d930
Update Dockerfile
astrosnat Aug 26, 2024
47cb345
Update compose_dev.sh
astrosnat Aug 26, 2024
18e7b49
add failure condition test
j4qfrost Aug 26, 2024
c7690d1
Merge branch 'upstream/main'
j4qfrost Aug 27, 2024
de31424
Merge remote-tracking branch 'upstream/golang123'
j4qfrost Aug 27, 2024
3646abe
formatting and test standards
j4qfrost Aug 28, 2024
0a7fcf0
Merge branch 'main' of github.com:openpredictionmarkets/socialpredict
j4qfrost Sep 7, 2024
df26051
Merge branch 'main' of github.com:openpredictionmarkets/socialpredict
j4qfrost Sep 7, 2024
6cbb97c
add frontend file polling for wsl2
j4qfrost Sep 7, 2024
8f86e23
Merge branch 'main' of github.com:openpredictionmarkets/socialpredict
j4qfrost Sep 9, 2024
564ad6b
Add test for HandleHTTPError (#278)
j4qfrost Aug 28, 2024
88b4854
add failure condition test (#282)
j4qfrost Aug 29, 2024
a2ccc58
Creation of Market Price Projection API (#277)
pwdel Aug 30, 2024
a1e039c
Create SECURITY.md
pwdel Sep 4, 2024
17e26a5
Adding Fees to Buying and Selling Bets (#287)
pwdel Sep 7, 2024
327e906
Frontend fixes (#286)
markokovac16 Sep 7, 2024
f10fdde
Attempting toa ddress cors related security concern. (#298)
pwdel Sep 7, 2024
f1b4d43
Drafting out reporting stats.
pwdel Sep 7, 2024
4cc882e
Add support for dependency injection to setup (#301)
ajlacey Sep 8, 2024
29eaddf
Merge branch 'upstream/main'
j4qfrost Sep 9, 2024
9692361
Merge branch 'main' of github.com:openpredictionmarkets/socialpredict
j4qfrost Sep 12, 2024
61827a6
Merge branch 'main' of github.com:openpredictionmarkets/socialpredict
j4qfrost Sep 23, 2024
df4f062
revert
j4qfrost Sep 23, 2024
25a691b
feat(frontend): Compiles frontend into single js file for performance
j4qfrost Sep 23, 2024
2bae8eb
forgot merge
j4qfrost Sep 23, 2024
905ba2d
Merge branch 'main' of github.com:openpredictionmarkets/socialpredict…
j4qfrost Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions backend/handlers/setup/setuphandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import (
"socialpredict/setup"
)

func GetSetupHandler(w http.ResponseWriter, r *http.Request) {
func GetSetupHandler(loadEconomicsConfig func() (*setup.EconomicConfig, error)) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
appConfig, err := loadEconomicsConfig()
if err != nil {
http.Error(w, "Failed to load economic config", http.StatusInternalServerError)
return
}

appConfig, err := setup.LoadEconomicsConfig()
if err != nil {
http.Error(w, "Failed to load economic config", http.StatusInternalServerError)
return
}

w.Header().Set("Content-Type", "application/json")
err = json.NewEncoder(w).Encode(appConfig.Economics)
if err != nil {
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
w.Header().Set("Content-Type", "application/json")
err = json.NewEncoder(w).Encode(appConfig.Economics)
if err != nil {
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
}
}
}
15 changes: 10 additions & 5 deletions backend/handlers/setup/setuphandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"testing"
)

var loadEconomicsConfig = setup.LoadEconomicsConfig

func TestGetSetupHandler(t *testing.T) {
tests := []struct {
Name string
Expand All @@ -31,22 +29,29 @@ func TestGetSetupHandler(t *testing.T) {
"User":{"InitialAccountBalance":0,"MaximumDebtAllowed":500},
"Betting":{"MinimumBet":1,"BetFees":{"InitialBetFee":1,"EachBetFee":0,"SellSharesFee":0}}}`,
IsJSONResponse: true,
}, {
Name: "failed to load config",
MockConfigLoader: func() (*setup.EconomicConfig, error) {
return nil, http.ErrBodyNotAllowed
},
ExpectedStatus: http.StatusInternalServerError,
ExpectedResponse: "Failed to load economic config",
IsJSONResponse: false,
},
}

for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
// Replace the actual loader function with the mock
loadEconomicsConfig = test.MockConfigLoader
defer func() { loadEconomicsConfig = setup.LoadEconomicsConfig }()
loadEconomicsConfig := test.MockConfigLoader

req, err := http.NewRequest("GET", "/setup", nil)
if err != nil {
t.Fatal(err)
}

rr := httptest.NewRecorder()
handler := http.HandlerFunc(GetSetupHandler)
handler := http.HandlerFunc(GetSetupHandler(loadEconomicsConfig))

handler.ServeHTTP(rr, req)

Expand Down
3 changes: 2 additions & 1 deletion backend/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
setuphandlers "socialpredict/handlers/setup"
usershandlers "socialpredict/handlers/users"
"socialpredict/middleware"
"socialpredict/setup"

"github.com/gorilla/mux"
"github.com/rs/cors"
Expand All @@ -36,7 +37,7 @@ func Start() {
router.HandleFunc("/v0/login", middleware.LoginHandler)

// application setup information
router.HandleFunc("/v0/setup", setuphandlers.GetSetupHandler).Methods("GET")
router.HandleFunc("/v0/setup", setuphandlers.GetSetupHandler(setup.LoadEconomicsConfig)).Methods("GET")
// markets display, market information
router.HandleFunc("/v0/markets", marketshandlers.ListMarketsHandler).Methods("GET")
router.HandleFunc("/v0/markets/{marketId}", marketshandlers.MarketDetailsHandler).Methods("GET")
Expand Down