-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ea1ad0
commit cbda2de
Showing
26 changed files
with
961 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
root = "." | ||
testdata_dir = "testdata" | ||
tmp_dir = "tmp" | ||
|
||
[build] | ||
args_bin = [] | ||
bin = "./main" | ||
cmd = "make build" | ||
delay = 1000 | ||
exclude_dir = ["assets", "tmp", "vendor", "testdata"] | ||
exclude_file = [] | ||
exclude_regex = ["_test.go"] | ||
exclude_unchanged = false | ||
follow_symlink = false | ||
full_bin = "" | ||
include_dir = [] | ||
include_ext = ["go", "tpl", "tmpl", "html"] | ||
include_file = [] | ||
kill_delay = "0s" | ||
log = "build-errors.log" | ||
poll = false | ||
poll_interval = 0 | ||
post_cmd = [] | ||
pre_cmd = [] | ||
rerun = false | ||
rerun_delay = 500 | ||
send_interrupt = false | ||
stop_on_error = false | ||
|
||
[color] | ||
app = "" | ||
build = "yellow" | ||
main = "magenta" | ||
runner = "green" | ||
watcher = "cyan" | ||
|
||
[log] | ||
main_only = false | ||
time = false | ||
|
||
[misc] | ||
clean_on_exit = false | ||
|
||
[screen] | ||
clear_on_rebuild = false | ||
keep_scroll = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with "go test -c" | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
tmp/ | ||
|
||
# IDE specific files | ||
.vscode | ||
.idea | ||
|
||
# .env file | ||
.env | ||
|
||
# Project build | ||
main | ||
*templ.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Simple Makefile for a Go project | ||
|
||
# Build the application | ||
all: build | ||
|
||
build: | ||
@echo "Building..." | ||
|
||
|
||
@go build -o main.exe cmd/api/main.go | ||
|
||
# Run the application | ||
run: | ||
@go run cmd/api/main.go | ||
|
||
# Create DB container | ||
docker-run: | ||
@if docker compose up 2>/dev/null; then \ | ||
: ; \ | ||
else \ | ||
echo "Falling back to Docker Compose V1"; \ | ||
docker-compose up; \ | ||
fi | ||
|
||
# Shutdown DB container | ||
docker-down: | ||
@if docker compose down 2>/dev/null; then \ | ||
: ; \ | ||
else \ | ||
echo "Falling back to Docker Compose V1"; \ | ||
docker-compose down; \ | ||
fi | ||
|
||
# Test the application | ||
test: | ||
@echo "Testing..." | ||
@go test ./tests -v | ||
|
||
# Clean the binary | ||
clean: | ||
@echo "Cleaning..." | ||
@rm -f main | ||
|
||
# Live Reload | ||
watch: | ||
air; | ||
|
||
## db/migrations/new name=$1: create a new database migration | ||
.PHONY: db/migrations/new | ||
db/migrations/new: | ||
@echo 'Creating migration files for ${name}...' | ||
migrate create -seq -ext=.sql -dir=./internal/database/migrations ${name} | ||
|
||
## db/migrations/up: apply all database up migrations | ||
.PHONY: db/migrations/up | ||
db/migrations/up: | ||
@echo 'Running Up migrations...' | ||
migrate -path=./internal/database/migrations -database postgres://postgres:root@localhost:5432/spotifycollab?sslmode=disable up | ||
|
||
## db/migrations/down: apply all database down migrations | ||
.PHONY: db/migrations/down | ||
db/migrations/down: | ||
@echo 'Running Down migrations...' | ||
migrate -path=./internal/database/migrations -database postgres://postgres:root@localhost:5432/spotifycollab?sslmode=disable down | ||
|
||
|
||
.PHONY: all build run test clean | ||
|
||
|
||
# # @if command -v air > /dev/null; then \ | ||
# air; \ | ||
# echo "Watching...";\ | ||
# else \ | ||
# read -p "Go's 'air' is not installed on your machine. Do you want to install it? [Y/n] " choice; \ | ||
# if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \ | ||
# go install github.com/air-verse/air@latest; \ | ||
# air; \ | ||
# echo "Watching...";\ | ||
# else \ | ||
# echo "You chose not to install air. Exiting..."; \ | ||
# exit 1; \ | ||
# fi; \ | ||
# fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"triton-backend/internal/server" | ||
) | ||
|
||
func main() { | ||
|
||
server := server.NewServer() | ||
|
||
err := server.ListenAndServe() | ||
if err != nil { | ||
panic(fmt.Sprintf("cannot start server: %s", err)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Project spotify-collab | ||
|
||
## Getting Started | ||
1. Create a psql database, edit the appropriate values in .env.example and rename to .env | ||
2. In makefile, under db/migrations/up and /down commands, edit the dsn of the db to match your own. | ||
3. Install the [migrate](https://github.com/golang-migrate/migrate/blob/master/cmd/migrate/README.md) tool with the appropriate driver tag(postgresql). Current command: `go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest` | ||
4. Run make db/migrations/up to run the migrations against your database. If you don't have make you can also copy paste the command | ||
5. If on Linux/Mac edit the make build command from main.exe to main | ||
6. Install air `go install github.com/air-verse/air@latest` | ||
7. Run `air` to start the server with live reloading | ||
|
||
## Changes to DB | ||
1. To create a new migration run db/migrations/new name={name} | ||
2. To make new queries add in the appropriate file in internal/database/queries. Check sqlc docs to see how to structure queries | ||
3. Run sqlc generate if any changes made in migrations/queries | ||
|
||
## Handlers & Services | ||
|
||
|
||
(Ignore below for now) | ||
## MakeFile | ||
|
||
run all make commands with clean tests | ||
```bash | ||
make all build | ||
``` | ||
|
||
build the application | ||
```bash | ||
make build | ||
``` | ||
|
||
run the application | ||
```bash | ||
make run | ||
``` | ||
|
||
Create DB container | ||
```bash | ||
make docker-run | ||
``` | ||
|
||
Shutdown DB container | ||
```bash | ||
make docker-down | ||
``` | ||
|
||
live reload the application | ||
```bash | ||
make watch | ||
``` | ||
|
||
run the test suite | ||
```bash | ||
make test | ||
``` | ||
|
||
clean up binary from the last build | ||
```bash | ||
make clean | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: '3.8' | ||
|
||
services: | ||
psql: | ||
image: postgres:latest | ||
environment: | ||
POSTGRES_DB: ${DB_DATABASE} | ||
POSTGRES_USER: ${DB_USERNAME} | ||
POSTGRES_PASSWORD: ${DB_PASSWORD} | ||
ports: | ||
- "${DB_PORT}:5432" | ||
volumes: | ||
- psql_volume:/var/lib/postgresql/data | ||
|
||
volumes: | ||
psql_volume: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module triton-backend | ||
|
||
go 1.22.2 | ||
|
||
require ( | ||
github.com/gin-gonic/gin v1.10.0 | ||
github.com/jackc/pgx/v5 v5.6.0 | ||
github.com/joho/godotenv v1.5.1 | ||
) | ||
|
||
require ( | ||
github.com/bytedance/sonic v1.12.1 // indirect | ||
github.com/bytedance/sonic/loader v0.2.0 // indirect | ||
github.com/cloudwego/base64x v0.1.4 // indirect | ||
github.com/cloudwego/iasm v0.2.0 // indirect | ||
github.com/gabriel-vasile/mimetype v1.4.5 // indirect | ||
github.com/gin-contrib/sse v0.1.0 // indirect | ||
github.com/go-playground/locales v0.14.1 // indirect | ||
github.com/go-playground/universal-translator v0.18.1 // indirect | ||
github.com/go-playground/validator/v10 v10.22.0 // indirect | ||
github.com/goccy/go-json v0.10.3 // indirect | ||
github.com/jackc/pgpassfile v1.0.0 // indirect | ||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect | ||
github.com/jackc/puddle/v2 v2.2.1 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/klauspost/cpuid/v2 v2.2.8 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/leodido/go-urn v1.4.0 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect | ||
github.com/rogpeppe/go-internal v1.12.0 // indirect | ||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect | ||
github.com/ugorji/go/codec v1.2.12 // indirect | ||
golang.org/x/arch v0.9.0 // indirect | ||
golang.org/x/crypto v0.26.0 // indirect | ||
golang.org/x/net v0.28.0 // indirect | ||
golang.org/x/sync v0.8.0 // indirect | ||
golang.org/x/sys v0.24.0 // indirect | ||
golang.org/x/text v0.17.0 // indirect | ||
google.golang.org/protobuf v1.34.2 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
Oops, something went wrong.