| 
						
						
						
					 | 
					 | 
					@ -1,4 +1,5 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					SQL_DATABASE?=./ratchet.db
 | 
					 | 
					 | 
					 | 
					SQL_DATABASE?=./ratchet.db
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					COVER_PROFILE?=./tmp/profile.out
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					# TODO maybe only use -race in an ARG for CI
 | 
					 | 
					 | 
					 | 
					# TODO maybe only use -race in an ARG for CI
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					FLAGS := -race -v 
 | 
					 | 
					 | 
					 | 
					FLAGS := -race -v 
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -11,34 +12,50 @@ endif
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					# make test ARGS=no-cache
 | 
					 | 
					 | 
					 | 
					# make test ARGS=no-cache
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					test:
 | 
					 | 
					 | 
					 | 
					test:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						go test $(FLAGS) ./...
 | 
					 | 
					 | 
					 | 
						go test $(FLAGS) ./...
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					PHONEY: test
 | 
					 | 
					 | 
					 | 
					.PHONY: test
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					test-short:
 | 
					 | 
					 | 
					 | 
					test-short:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						go test -short $(FLAGS) ./...
 | 
					 | 
					 | 
					 | 
						go test -short $(FLAGS) ./...
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					PHONEY: test-short
 | 
					 | 
					 | 
					 | 
					.PHONY: test-short
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					# make test-int ARGS=no-cache
 | 
					 | 
					 | 
					 | 
					# make test-int ARGS=no-cache
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					test-int:
 | 
					 | 
					 | 
					 | 
					test-int:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						go test $(FLAGS) ./cmd/...
 | 
					 | 
					 | 
					 | 
						go test $(FLAGS) ./cmd/...
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					.PHONY: test-int
 | 
					 | 
					 | 
					 | 
					.PHONY: test-int
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					cover-html: test-cover
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						go tool cover -html=$(COVER_PROFILE)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					.PHONY:cover-html
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					coverage: test-cover
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						go tool cover -func=$(COVER_PROFILE)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					.PHONY: coverage
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					test-cover:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						go test -coverprofile=$(COVER_PROFILE) $(FLAGS) ./...
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					.PHONY: test-cover
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					serve:
 | 
					 | 
					 | 
					 | 
					serve:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						go run ./cmd/ratchetd/main.go
 | 
					 | 
					 | 
					 | 
						go run ./cmd/ratchetd/main.go
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					PHONEY: serve
 | 
					 | 
					 | 
					 | 
					.PHONY: serve
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					# SQLite Commands
 | 
					 | 
					 | 
					 | 
					# SQLite Commands
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					sql-cli:
 | 
					 | 
					 | 
					 | 
					sql-cli:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						sqlite3 $(SQL_DATABASE) -cmd ".headers on" -cmd ".mode box" -cmd ".tables"
 | 
					 | 
					 | 
					 | 
						sqlite3 $(SQL_DATABASE) -cmd ".headers on" -cmd ".mode box" -cmd ".tables"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					.PHONY: sql-cli
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					init-db: run-migrate
 | 
					 | 
					 | 
					 | 
					init-db: run-migrate
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						sqlite3 $(SQL_DATABASE) "PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;"
 | 
					 | 
					 | 
					 | 
						sqlite3 $(SQL_DATABASE) "PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					.PHONY: init-db
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					seed-db:
 | 
					 | 
					 | 
					 | 
					seed-db:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						sqlite3 $(SQL_DATABASE) "INSERT INTO snippets (title, content, expires_at) VALUES ('placeholder', 'placeholder content', datetime('now', '+6 months'));"
 | 
					 | 
					 | 
					 | 
						sqlite3 $(SQL_DATABASE) "INSERT INTO snippets (title, content, expires_at) VALUES ('placeholder', 'placeholder content', datetime('now', '+6 months'));"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					.PHONY: seed-db
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					run-migrate:
 | 
					 | 
					 | 
					 | 
					run-migrate:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						migrate -database sqlite3://$(SQL_DATABASE) -path ./migrations up
 | 
					 | 
					 | 
					 | 
						migrate -database sqlite3://$(SQL_DATABASE) -path ./migrations up
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					.PHONY: run-migrate
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					# Checks system dependencies needed to run the local dev environment
 | 
					 | 
					 | 
					 | 
					# Checks system dependencies needed to run the local dev environment
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					check-system-deps:
 | 
					 | 
					 | 
					 | 
					check-system-deps:
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -47,8 +64,9 @@ check-system-deps:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@command -v sqlite3 > /dev/null || (echo "Missing sqlite3 command. brew install sqlite"; exit 1)
 | 
					 | 
					 | 
					 | 
						@command -v sqlite3 > /dev/null || (echo "Missing sqlite3 command. brew install sqlite"; exit 1)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@command -v migrate > /dev/null || (echo "Missing migrate command. go install -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@latest"; exit 1)
 | 
					 | 
					 | 
					 | 
						@command -v migrate > /dev/null || (echo "Missing migrate command. go install -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@latest"; exit 1)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@echo "System dependencies fulfilled 👍"
 | 
					 | 
					 | 
					 | 
						@echo "System dependencies fulfilled 👍"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					.PHONY: check-system-deps
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					# Certs
 | 
					 | 
					 | 
					 | 
					# Certs
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					local-certs:
 | 
					 | 
					 | 
					 | 
					local-certs:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						cd ./tls && go run /usr/local/go/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost
 | 
					 | 
					 | 
					 | 
						cd ./tls && go run /usr/local/go/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					.PHONY: local-certs
 |