Skip to content

Commit

Permalink
Merge pull request #26 from jonhealy1/fresh-update
Browse files Browse the repository at this point in the history
Update readme, add es root route
  • Loading branch information
jonhealy1 authored Mar 18, 2024
2 parents e1f572d + 6836bd2 commit 4290cae
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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```

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions es-api/controllers/es-collection-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions es-api/router/es_collection_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4290cae

Please sign in to comment.