Skip to content

Commit

Permalink
Merge pull request #7 from andreasgan/master
Browse files Browse the repository at this point in the history
search
  • Loading branch information
andreasgangso authored Dec 6, 2021
2 parents 409e0ac + 1c58ab1 commit 7a4a184
Show file tree
Hide file tree
Showing 22 changed files with 489 additions and 47 deletions.
4 changes: 4 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ tasks:
- init: |
make dependencies # runs during prebuild
gp sync-done dependencies
- name: Docker
init: gp sync-await dependencies
command: docker-compose up -d
openMode: split-right
- name: Admin Frontend
init: gp sync-await dependencies
command: make admin-backend
Expand Down
29 changes: 15 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
help: .PHONY
echo "Read the Makefile, im too lazy"

dependencies:
dependencies: .PHONY
npm install -g pnpm
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
go install github.com/kyleconroy/sqlc/cmd/sqlc@latest

local-setup:
local-setup: .PHONY
cp backend/.env.example backend/.env
docker-compose up -d
cd local-setup && docker-compose up -d
make migrate
docker-compose down
cd frontend/admin
pnpm install
cd local-setup && docker-compose down
cd frontend/admin && pnpm install

admin-frontend:
cd ./frontend/admin/
pnpm start
admin-frontend: .PHONY
cd ./frontend/admin/ && pnpm start

admin-backend:
admin-backend: .PHONY
cd ./backend/admin/ && go run .

migrate:
m: .PHONY
@echo migrate -database "postgres://postgres:password@localhost:5432/postgres?sslmode=disable" -path ./backend/db/migrations

migrate: .PHONY
migrate -database "postgres://postgres:password@localhost:5432/postgres?sslmode=disable" -path ./backend/db/migrations up

mock:
mock: .PHONY
mock-dev custom -f ./backend/db/mock/mock_skeleton.yaml --database postgres -v --password password

test-build:
test-build: .PHONY
docker build -t brunstadtv-admin-test:latest -f ./backend/Dockerfile.test ./backend --progress=plain

test:
test: .PHONY
make test-build
cd backend && go test ./... -v
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

### First steps

- Run `docker-compose up` in the repository root folder. This sets up a postgres database and Typesense.
- Run `docker-compose up` in the /local-setup folder. This sets up a postgres database and Typesense.
- Run migrations. See [Migrations](#migrations)
- Open the go project at `backend/admin/` (or run `make admin-backend`)
- Open `frontend` and run `pnpm install` and `pnpm start`
Expand Down
3 changes: 1 addition & 2 deletions backend/admin/assets.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"context"
"fmt"
"net/http"
"reflect"
Expand All @@ -15,7 +14,7 @@ import (
)

func (s *Server) GetAsset(c *gin.Context) {
ctx := context.Background()
ctx := c.Request.Context()
idString, _ := c.Params.Get("id")
id, err := strconv.ParseInt(idString, 10, 64)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions backend/admin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func main() {
MaxAge: 12 * time.Hour,
}))

r.POST("/index", search.Index)
r.POST("/search/sync", search.Synchronize)
r.GET("/tags", s.GetTags)
r.GET("/tags/:id", s.GetTag)
r.PUT("/tags/:id", s.UpsertTag)
Expand Down Expand Up @@ -119,5 +119,5 @@ func main() {
r.POST("/subclip", subclip.Create)
r.GET("/subclip/:id", subclip.Get)
r.PUT("/subclip/:id", subclip.Update)
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
r.Run("0.0.0.0:8080") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
7 changes: 3 additions & 4 deletions backend/admin/medias.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"context"
"fmt"
"net/http"
"reflect"
Expand All @@ -20,7 +19,7 @@ type MediaServer struct {
}

func (s *MediaServer) Get(c *gin.Context) {
ctx := context.Background()
ctx := c.Request.Context()
idString, _ := c.Params.Get("id")
id, err := strconv.ParseInt(idString, 10, 64)
if err != nil {
Expand Down Expand Up @@ -126,7 +125,7 @@ func (s *MediaServer) Create(c *gin.Context) {
params.MediaType = null.StringFrom(s.FilterByType)
}
// os.Getenv("DATABASE_URL")
ctx := context.Background()
ctx := c.Request.Context()
media, err := s.Server.queries.InsertMedia(ctx, params)
if err != nil {
fmt.Println(err)
Expand Down Expand Up @@ -155,7 +154,7 @@ func (s *MediaServer) Update(c *gin.Context) {
return
}
// os.Getenv("DATABASE_URL")
ctx := context.Background()
ctx := c.Request.Context()
media, err := s.Server.queries.UpsertMedia(ctx, params)
if err != nil {
fmt.Println(err)
Expand Down
Loading

0 comments on commit 7a4a184

Please sign in to comment.