diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index e69de29..0000000 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 3d498ee..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Fabio Esposito - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Makefile b/Makefile deleted file mode 100644 index e161546..0000000 --- a/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -.PHONY: all -all: - @echo 'To Do' \ No newline at end of file diff --git a/cmd/main.go b/cmd/main.go deleted file mode 100644 index e17fbd1..0000000 --- a/cmd/main.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "fmt" - "html/template" - "strings" - - h "graphdb-reco-engine/handlers" - - "github.com/gin-gonic/gin" -) - -func init() { - fmt.Println("init") -} - -func main() { - r := gin.Default() - r.SetFuncMap(template.FuncMap{ - "upper": strings.ToUpper, - }) - r.Static("/assets", "public_html/assets") - r.LoadHTMLGlob("public_html/templates/*.html") - - // App Routes - // Web pages - r.GET("/", h.IndexPage) - - // API endpoints - r.GET("/api/ping", h.PingEndpoint) - - r.Run("localhost:8080") -} diff --git a/scripts/redisgraph/seed.go b/cmd/redisgraph.go similarity index 73% rename from scripts/redisgraph/seed.go rename to cmd/redisgraph.go index 3101181..267df23 100644 --- a/scripts/redisgraph/seed.go +++ b/cmd/redisgraph.go @@ -9,41 +9,11 @@ import ( ) func main() { + conn, _ := redis.Dial("tcp", "127.0.0.1:6379") defer conn.Close() graph := rg.GraphNew("social", conn) - - graph.Delete() - - john := rg.Node{ - Label: "person", - Properties: map[string]interface{}{ - "name": "John Doe", - "age": 33, - "gender": "male", - "status": "single", - }, - } - graph.AddNode(&john) - - japan := rg.Node{ - Label: "country", - Properties: map[string]interface{}{ - "name": "Japan", - }, - } - graph.AddNode(&japan) - - edge := rg.Edge{ - Source: &john, - Relation: "visited", - Destination: &japan, - } - graph.AddEdge(&edge) - - graph.Commit() - query := `MATCH (p:person)-[v:visited]->(c:country) RETURN p.name, p.age, c.name` @@ -79,4 +49,5 @@ func main() { p, ok := r.GetByIndex(0).(rg.Path) fmt.Printf("%s %v\n", p, ok) } + } diff --git a/cmd/seed/seed.go b/cmd/seed/seed.go new file mode 100644 index 0000000..700839c --- /dev/null +++ b/cmd/seed/seed.go @@ -0,0 +1,43 @@ +package seed + +import ( + "github.com/gomodule/redigo/redis" + rg "github.com/redislabs/redisgraph-go" +) + +func main() { + conn, _ := redis.Dial("tcp", "127.0.0.1:6379") + defer conn.Close() + + graph := rg.GraphNew("social", conn) + + graph.Delete() + + john := rg.Node{ + Label: "person", + Properties: map[string]interface{}{ + "name": "John Doe", + "age": 33, + "gender": "male", + "status": "single", + }, + } + graph.AddNode(&john) + + japan := rg.Node{ + Label: "country", + Properties: map[string]interface{}{ + "name": "Japan", + }, + } + graph.AddNode(&japan) + + edge := rg.Edge{ + Source: &john, + Relation: "visited", + Destination: &japan, + } + graph.AddEdge(&edge) + graph.Commit() + +} diff --git a/handlers/api.go b/handlers/api.go deleted file mode 100644 index d1056e6..0000000 --- a/handlers/api.go +++ /dev/null @@ -1,13 +0,0 @@ -package handlers - -import ( - "net/http" - - "github.com/gin-gonic/gin" -) - -func PingEndpoint(c *gin.Context) { - c.JSON(http.StatusOK, gin.H{ - "message": "this is coming from an API call", - }) -} diff --git a/handlers/web.go b/handlers/web.go deleted file mode 100644 index d9aa013..0000000 --- a/handlers/web.go +++ /dev/null @@ -1,13 +0,0 @@ -package handlers - -import ( - "net/http" - - "github.com/gin-gonic/gin" -) - -func IndexPage(c *gin.Context) { - c.HTML(http.StatusOK, "index.html", gin.H{ - "content": "This is a content coming from golang...", - }) -} diff --git a/public_html/templates/index.html b/public_html/templates/index.html deleted file mode 100644 index 467d262..0000000 --- a/public_html/templates/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - Go HTMX Example - - - -

{{ .content }}

- - - - \ No newline at end of file diff --git a/repositories/redisgraph.go b/repositories/redisgraph.go deleted file mode 100644 index 3f43206..0000000 --- a/repositories/redisgraph.go +++ /dev/null @@ -1 +0,0 @@ -package repositories