Skip to content

Commit

Permalink
chore(server): install air and add dev command for hotreload (#1337)
Browse files Browse the repository at this point in the history
Co-authored-by: YuyaSoneda <[email protected]>
  • Loading branch information
soneda-yuya and YuyaSoneda authored Jan 8, 2025
1 parent 189fdab commit 42e2b7b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
26 changes: 26 additions & 0 deletions server/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# project root directory
root = "."
tmp_dir = "tmp"

[build]
# execute command
cmd = "go build -o ./tmp/api ./cmd/reearth"
bin = "tmp/api"
full_bin = "tmp/api"
delay = 1000 # ms
stop_on_error = true
send_interrupt = false
kill_delay = 1000 # ms

# include file extensions
include_ext = ["go"]

# exclude directories
exclude_dir = ["e2e", "tmp"]

# exclude files
exclude_file = ["*_test.go"]

[log]
# Air log settings
level = "debug"
1 change: 1 addition & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ __debug_bin
!/.env.example
/coverage.txt
/web
tmp
18 changes: 17 additions & 1 deletion server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ TEST_DIR ?= ./...
SCHEMATYPER := github.com/idubinskiy/schematyper
MANIFEST_DIR := pkg/plugin/manifest

default: help

help:
@echo "Usage:"
@echo " make <target>"
Expand All @@ -13,6 +15,8 @@ help:
@echo " failcheck Run unit tests with fail-fast and no parallel execution"
@echo " e2e Run end-to-end tests"
@echo " build Build the project"
@echo " dev-install Install tools for make dev - behavior not confirmed in windows."
@echo " dev Run the application with hot reloading"
@echo " run-app Run the application"
@echo " run-db Run the MongoDB database using Docker Compose"
@echo " gql Generate GraphQL code include dataloader"
Expand All @@ -34,6 +38,18 @@ e2e:
build:
go build ./cmd/reearth

AIR_BIN := $(shell which air)
dev-install:
ifndef AIR_BIN
@echo "reflex is not installed. Installing..."
@go install github.com/air-verse/[email protected]
else
@echo "air is already installed."
endif

dev: dev-install
air

run-app:
go run ./cmd/reearth

Expand All @@ -51,4 +67,4 @@ schematyper:
go run $(SCHEMATYPER) -o $(MANIFEST_DIR)/schema_translation.go --package manifest --prefix Translation ./schemas/plugin_manifest_translation.json
go run $(SCHEMATYPER) -o $(MANIFEST_DIR)/schema_gen.go --package manifest ./schemas/plugin_manifest.json

.PHONY: lint test failcheck e2e build run-app run-db gql mockuser schematyper
.PHONY: lint test failcheck e2e build dev-install dev run-app run-db gql mockuser schematyper
2 changes: 1 addition & 1 deletion server/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func initEcho(ctx context.Context, cfg *ServerConfig) *echo.Echo {
apiPrivate.GET("/layers/:param", ExportLayer(), AuthRequiredMiddleware())
apiPrivate.GET("/datasets/:datasetSchemaId", http2.ExportDataset(), AuthRequiredMiddleware())
apiPrivate.POST("/signup", Signup())

log.Infofc(ctx, "auth: config: %#v", cfg.Config.AuthSrv)
if !cfg.Config.AuthSrv.Disabled {
apiPrivate.POST("/signup/verify", StartSignupVerify())
apiPrivate.POST("/signup/verify/:code", SignupVerify())
Expand Down

0 comments on commit 42e2b7b

Please sign in to comment.