devex
This commit is contained in:
parent
7b8cdcfd7b
commit
143caaac2b
9 changed files with 115 additions and 10 deletions
52
.air.toml
Normal file
52
.air.toml
Normal file
|
@ -0,0 +1,52 @@
|
|||
root = "."
|
||||
testdata_dir = "testdata"
|
||||
tmp_dir = "tmp"
|
||||
|
||||
[build]
|
||||
args_bin = []
|
||||
bin = "./tmp/main"
|
||||
cmd = "go build -o ./tmp/main ."
|
||||
delay = 1000
|
||||
exclude_dir = ["assets", "tmp", "vendor", "testdata", "scripts"]
|
||||
exclude_file = []
|
||||
exclude_regex = ["_test.go"]
|
||||
exclude_unchanged = false
|
||||
follow_symlink = false
|
||||
full_bin = ""
|
||||
include_dir = []
|
||||
include_ext = ["go", "tpl", "tmpl", "html", "css", "js", "svg", "png"]
|
||||
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
|
||||
silent = false
|
||||
time = false
|
||||
|
||||
[misc]
|
||||
clean_on_exit = false
|
||||
|
||||
[proxy]
|
||||
app_port = 8169
|
||||
enabled = true
|
||||
proxy_port = 8170
|
||||
|
||||
[screen]
|
||||
clear_on_rebuild = false
|
||||
keep_scroll = true
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
.direnv
|
||||
.env
|
||||
.storage
|
||||
result
|
||||
result
|
||||
tmp
|
40
README.md
40
README.md
|
@ -4,9 +4,45 @@ yeah 4 of em..
|
|||
|
||||
## Developing
|
||||
|
||||
use `nix shell` or `nix-shell` or maybe just run `go run .` or somethin its ok
|
||||
highly recommended to use nix. its actually optional, but there's caveats.
|
||||
|
||||
please run `just precommit` before committing thx, it fixes weird build issues
|
||||
**Quickstart**
|
||||
|
||||
```sh
|
||||
## - Step one, get an environment!
|
||||
nix develop
|
||||
# or
|
||||
nix-shell
|
||||
# or
|
||||
direnv allow
|
||||
|
||||
## - Step two, setup .env
|
||||
cp .env.example .env
|
||||
# fill out .env (the file has instructions)
|
||||
|
||||
## - Step three, run the thing!!
|
||||
just
|
||||
# or .. maybe this.. but it may be unpredictable
|
||||
go run .
|
||||
|
||||
## - Step four, clean up the code
|
||||
just precommit
|
||||
```
|
||||
|
||||
> _the caveat: using `go` alone is doable. certain things won't happen, like dependency tagging and env var loading, so.. consider `nix`.._
|
||||
|
||||
### just commands
|
||||
|
||||
- **watch** - (default) runs air livereloader
|
||||
- open https://localhost:8170 for live reloading, note: the console will output 8169. that works too, but doesn't reload browser on changes
|
||||
- **run** - runs the app with go run
|
||||
- **nix-run** - runs the app built via nix (slower)
|
||||
- **run-container** - builds the app as a docker image, then runs it. (slowest)
|
||||
- **fmt** - go fmt and prettier
|
||||
- **tidy** - fix gomods
|
||||
- **test** - runs normal tests
|
||||
- **update-vendor-hash** - updates `default.nix` vendorHash field, it won't build without it.
|
||||
- **precommit** - runs fmt, tidy, update-vendor-hash, and test, in that order.
|
||||
|
||||
## Deploying
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@ func TestPostHandler(t *testing.T) {
|
|||
func TestPostHandlerIntegration(t *testing.T) {
|
||||
i, dsm, key := makeInteractions(t)
|
||||
app := roleypoly.CreateFiberApp()
|
||||
|
||||
// Tests that everything works including auth middleware
|
||||
sessionMiddleware, sessionStore := session.NewWithStore()
|
||||
sessionStore.RegisterType(authmiddleware.Session{})
|
||||
app.Use(sessionMiddleware)
|
||||
|
|
9
justfile
9
justfile
|
@ -1,3 +1,6 @@
|
|||
watch:
|
||||
air
|
||||
|
||||
run:
|
||||
go run .
|
||||
|
||||
|
@ -15,11 +18,13 @@ fmt:
|
|||
go fmt ./...
|
||||
|
||||
tidy:
|
||||
go clean -modcache
|
||||
go mod tidy
|
||||
|
||||
update-vendor-hash:
|
||||
scripts/update-vendor-hash.sh
|
||||
|
||||
test:
|
||||
go test ./...
|
||||
go test ./...
|
||||
|
||||
clean-repo:
|
||||
rm -rf tmp result
|
10
main.go
10
main.go
|
@ -20,9 +20,13 @@ func main() {
|
|||
roleypoly.SetupStatic(app)
|
||||
roleypoly.SetupControllers(
|
||||
app,
|
||||
dc,
|
||||
utils.DiscordPublicKey,
|
||||
utils.PublicBaseURL,
|
||||
roleypoly.ControllerConfig{
|
||||
DiscordClient: dc,
|
||||
PublicKey: utils.DiscordPublicKey,
|
||||
PublicBaseURL: utils.PublicBaseURL,
|
||||
SupportIDs: utils.SupportIDs,
|
||||
SuperuserIDs: utils.SupueruserIDs,
|
||||
},
|
||||
)
|
||||
|
||||
log.Fatal(app.Listen(utils.ListenAddr))
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
go
|
||||
just
|
||||
nil
|
||||
just
|
||||
air
|
||||
];
|
||||
}
|
||||
|
|
0
templates/tests/landing.html
Normal file
0
templates/tests/landing.html
Normal file
|
@ -1,6 +1,9 @@
|
|||
package utils
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
DiscordBotToken = os.Getenv("DISCORD_BOT_TOKEN")
|
||||
|
@ -9,4 +12,6 @@ var (
|
|||
DiscordPublicKey = os.Getenv("DISCORD_PUBLIC_KEY")
|
||||
ListenAddr = Or(os.Getenv("LISTEN_ADDR"), ":8169")
|
||||
PublicBaseURL = os.Getenv("PUBLIC_BASE_URL")
|
||||
SupportIDs = strings.Split(os.Getenv("SUPPORT_IDS"), ",")
|
||||
SupueruserIDs = strings.Split(os.Getenv("SUPERUSER_IDS"), ",")
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue