Skip to content

Commit

Permalink
Preapre spa
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-kg committed Jun 18, 2024
1 parent 59e9089 commit 2dfe571
Show file tree
Hide file tree
Showing 32 changed files with 612 additions and 322 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,12 @@ docker run --net=host --volume /home/user/ctf01d-training-platform/api:/api/ ghc
docker run --net=host --volume /home/user/ctf01d-training-platform/api:/api/ kisspeter/apifuzzer --src_file '/api/swagger.yaml' --url http://localhost:4102 -r /api/
```


## oapi-codegen

install:

```
$ go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
$ export PATH="$PATH:$HOME/bin:$HOME/go/bin"
```
12 changes: 7 additions & 5 deletions cmd/ctf01d/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ func main() {
}
slog.Info("Database connection established successfully")
defer db.Close()
r := chi.NewRouter()
h := &handlers.Handlers{
router := chi.NewRouter() // TODO .StrictSlash(true)
hndlrs := &handlers.Handlers{
DB: db,
}
s := handlers.NewServerInterfaceWrapper(h)
svr := handlers.NewServerInterfaceWrapper(hndlrs)

r.Mount("/", server.HandlerFromMux(s, r))
err = http.ListenAndServe(cfg.HTTP.Host+":"+cfg.HTTP.Port, r)
router.Mount("/api/", server.HandlerFromMux(svr, router))
router.Mount("/", http.HandlerFunc(server.NewHtmlRouter))

err = http.ListenAndServe(cfg.HTTP.Host+":"+cfg.HTTP.Port, router)
if err != nil {
slog.Error("Server error: " + err.Error())
}
Expand Down
7 changes: 7 additions & 0 deletions html/assets/css/bootstrap-grid.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions html/assets/css/bootstrap-grid.min.css.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions html/assets/css/bootstrap-reboot.min.css

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

1 change: 1 addition & 0 deletions html/assets/css/bootstrap-reboot.min.css.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions html/assets/css/bootstrap.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions html/assets/css/bootstrap.min.css.map

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions html/assets/css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*body{
background-color: #000;
font: 12pt/10pt Arial;
color: #999;
padding: 0px;
margin: 0px;
background-color: #202020;
color: #aaa;
}
body,html{
height: 100%;
text-align: center;
}*/


#menu_global {
padding-left: 20px;
padding-right: 20px;
}

.spa-web-page {
display: none;
}

.nav-item .nav-link {
cursor: pointer;
}

.btn-menu-top-left {
margin-left: 10px;
}
42 changes: 42 additions & 0 deletions html/assets/js/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

if(!window.ctf01d_tp_api) window.ctf01d_tp_api = {};

window.ctf01d_tp_api.games_list = function() {
return $.ajax({
url: '/api/games',
method: 'GET',
});
}

window.ctf01d_tp_api.game_info = function(game_id) {
return $.ajax({
url: '/api/games/' + game_id,
method: 'GET',
});
}

window.ctf01d_tp_api.game_create = function(game_data) {
return $.ajax({
url: '/api/games',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify(game_data),
});
}

window.ctf01d_tp_api.auth_signin = function(auth_data) {
return $.ajax({
url: '/api/login',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify(auth_data),
});
}

window.ctf01d_tp_api.auth_session = function() {
return $.ajax({
url: '/api/auth/session',
method: 'GET',
contentType: 'application/json',
});
}
2 changes: 2 additions & 0 deletions html/assets/js/bootstrap-notify.min.js

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

7 changes: 7 additions & 0 deletions html/assets/js/bootstrap.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions html/assets/js/bootstrap.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 2dfe571

Please sign in to comment.