This service uses Go and PostgreSQL.
We welcome contributions! Please see our Contributing Guidelines for more details.
.
├── api # openapi schema
│ └── openapi.yaml
├── build # docker files
│ ├── docker-compose.stage.yml
│ ├── docker-compose.yml
│ └── Dockerfile
├── cmd # main app
│ └── main.go
├── configs # app config and other config (linter)
│ ├── config.development.yml
│ ├── config.production.yml
│ ├── config.test.yml
│ ├── golangci
│ │ └── golangci.yml
│ └── spectral
│ └── spectral.yaml
├── docs # project documentation
│ └── *.md
├── html # current frontend
├── internal
│ ├── config
│ │ └── config.go
│ ├── handler # backend handlers
│ │ └── *.go
│ ├── helper # shared code
│ │ └── helper.go
│ ├── logger
│ │ └── logger.go
│ ├── migrations # sql migrations
│ │ └── psql
│ │ ├── struct_updater.go
│ │ └── update*.go
│ ├── model # api json template
│ │ └── *.go
│ ├── repository # work with db, query ...
│ │ └── *.go
│ ├── httpserver # autogenerated code from oapi-codegen
│ │ ├── html_spa.go
│ │ └── httpserver.gen.go
│ └── view
│ └── session.go
├── pkg
│ └── avatar # uniq pic for user
│ └── avatar.go
├── scripts
│ └── create-migration.go # make new file for migration
└── test
└── server_integration_test.go
$ snap install go --classic
also you will need docker
$ make run-db
...
$ make build
$ ./main
And then open http://localhost:4102/
Default admin credentials: admin/admin
$ go mod download && go mod tidy
$ go build cmd/main.go
$ go run cmd/main.go
will be available on - http://localhost:4102
oapi-codegen -generate models,chi -o internal/server/httpserver.gen.go --package routers api/openapi.yaml
connect to db configure in src/configs/config.#{STAGE}.yaml
...
db:
driver: postgres
data_source: postgres://postgres@localhost:5432/ctf01d
...
$ docker run -d --name ctf01d-postgres -e POSTGRES_DB=ctf01d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres
$ docker exec -it ctf01d-postgres psql -U postgres
go run scripts/create-migration.go # Created new migration file: internal/migrations/psql/update0022_update0023.go
docker run --net=host --volume /home/user/ctf01d-training-platform/api:/api/ ghcr.io/matusf/openapi-fuzzer run -s '/api/openapi.yaml' --url http://localhost:4102
docker run --net=host --volume /home/user/ctf01d-training-platform/api:/api/ kisspeter/apifuzzer --src_file '/api/openapi.yaml' --url http://localhost:4102 -r /api/
install:
$ go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
$ export PATH="$PATH:$HOME/bin:$HOME/go/bin"
$ make run-db
$ psql postgresql://postgres:postgres@localhost:4112/ctf01d_training_platform
ctf01d_training_platform=#