commit 2f853b3ade8338b8fcb27030098b3dc29e815667 Author: Kofo Okesola Date: Fri Oct 4 04:58:44 2024 +0100 init commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4befed3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +.idea diff --git a/apiconfig/apiconfig.go b/apiconfig/apiconfig.go new file mode 100644 index 0000000..c23d587 --- /dev/null +++ b/apiconfig/apiconfig.go @@ -0,0 +1,58 @@ +package apiconfig + +import "encoding/json" + +type RequestType string + +const ( + JSON RequestType = "json" + FormData RequestType = "form-data" +) + +type APIConfig struct { + ID string `json:"id"` + ListenPath string `json:"listenPath"` + Method string `json:"method"` + Request RequestConfig `json:"request"` + Actions map[string]Action `json:"actions"` + Conditionals map[string]Conditional `json:"conditionals"` + Responses map[string]ResponseConfig `json:"responses"` +} + +type RequestConfig struct { + Type RequestType `json:"type"` + Schema string `json:"schema"` + FormValues []string `json:"formValues"` + Next string `json:"next"` + CORSAllowedOrigins []string `json:"corsAllowedOrigins"` +} + +type Action struct { + Type string `json:"type"` + Config json.RawMessage `json:"config"` + Next string `json:"next"` +} + +type ConditionalExpressions struct { + Value string `json:"value"` + Type string `json:"type"` + Compare string `json:"compare,omitempty"` +} + +type Conditional struct { + ValidPath string `json:"validPath"` + InvalidPath string `json:"invalidPath"` + Expression string `json:"expression"` +} + +type ActionConfig struct { + ID string + Type string + Configuration string +} + +type ResponseConfig struct { + Code int `json:"code"` + Template string `json:"template"` + Type string `json:"type"` +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..05bfad5 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.servflow.io/servflow/servflow-definitions + +go 1.22.4