From 58d2178500b6aba230003426e2a06bbfb537af77 Mon Sep 17 00:00:00 2001 From: jonhealy1 Date: Mon, 18 Mar 2024 11:39:29 +0800 Subject: [PATCH 1/3] update es db version --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 23a6003..ba4977a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,7 +59,7 @@ services: command: postgres -N 500 elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:7.15.2 + image: docker.elastic.co/elasticsearch/elasticsearch:8.1.3 container_name: elasticsearch environment: - discovery.type=single-node From 2aae61a45eacc862d77f5658bddfd11e812be9d0 Mon Sep 17 00:00:00 2001 From: jonhealy1 Date: Mon, 18 Mar 2024 11:59:16 +0800 Subject: [PATCH 2/3] add elasticsearch root route --- .../controllers/es-collection-controller.go | 28 +++++++++++++++++++ es-api/router/es_collection_routes.go | 1 + 2 files changed, 29 insertions(+) diff --git a/es-api/controllers/es-collection-controller.go b/es-api/controllers/es-collection-controller.go index c331553..08f06f5 100644 --- a/es-api/controllers/es-collection-controller.go +++ b/es-api/controllers/es-collection-controller.go @@ -16,6 +16,34 @@ import ( "github.com/jonhealy1/goapi-stac/es-api/models" ) + +func Root(c *fiber.Ctx) error { + links := []models.Link{ + { + Rel: "self", + Type: "application/json", + Href: "/", + Title: "root catalog", + }, + { + Rel: "children", + Type: "application/json", + Href: "/collections", + Title: "stac child collections", + }, + } + + rootCatalog := models.Root{ + Id: "test-catalog", + StacVersion: "1.0.0", + Description: "test catalog for goapistac, please edit", + Title: "goapistac", + Links: links, + } + + return c.Status(http.StatusOK).JSON(rootCatalog) +} + func CreateESCollection(c *fiber.Ctx) error { stac_collection := new(models.StacCollection) err := c.BodyParser(&stac_collection) diff --git a/es-api/router/es_collection_routes.go b/es-api/router/es_collection_routes.go index df7851f..cb317d6 100644 --- a/es-api/router/es_collection_routes.go +++ b/es-api/router/es_collection_routes.go @@ -7,6 +7,7 @@ import ( ) func ESCollectionRoute(app *fiber.App) { + app.Get("/", controllers.Root) app.Post("/collections", controllers.CreateESCollection) app.Get("/collections/:collectionId", controllers.GetESCollection) app.Put("/collections/:collectionId", controllers.EditESCollection) From 6836bd25c4a0bf280174a89887d506abe280268c Mon Sep 17 00:00:00 2001 From: jonhealy1 Date: Mon, 18 Mar 2024 12:05:30 +0800 Subject: [PATCH 3/3] update readme --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5c2155e..59afef8 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ -# goapi-stac +# gostac-api ### a STAC api written in go with fiber, gorm, elasticsearch and postgres #### https://documenter.getpostman.com/view/12888943/VVBXwQnu ------- -### RUN LOCALLY (localhost:6002): -```$ make database``` +### RUN POSTGRES API LOCALLY (localhost:6002): +```$ docker compose up database``` +```$ cd pg-api``` +```$ go build``` +```$ go run app.go``` + +### RUN ELASTICSEARCH API LOCALLY (localhost:6003): +```$ docker compose up elasticsearch``` +```$ cd es-api``` ```$ go build``` ```$ go run app.go```