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
|
.direnv
|
||||||
.env
|
.env
|
||||||
.storage
|
.storage
|
||||||
result
|
result
|
||||||
|
tmp
|
40
README.md
40
README.md
|
@ -4,9 +4,45 @@ yeah 4 of em..
|
||||||
|
|
||||||
## Developing
|
## 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
|
## Deploying
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,8 @@ func TestPostHandler(t *testing.T) {
|
||||||
func TestPostHandlerIntegration(t *testing.T) {
|
func TestPostHandlerIntegration(t *testing.T) {
|
||||||
i, dsm, key := makeInteractions(t)
|
i, dsm, key := makeInteractions(t)
|
||||||
app := roleypoly.CreateFiberApp()
|
app := roleypoly.CreateFiberApp()
|
||||||
|
|
||||||
|
// Tests that everything works including auth middleware
|
||||||
sessionMiddleware, sessionStore := session.NewWithStore()
|
sessionMiddleware, sessionStore := session.NewWithStore()
|
||||||
sessionStore.RegisterType(authmiddleware.Session{})
|
sessionStore.RegisterType(authmiddleware.Session{})
|
||||||
app.Use(sessionMiddleware)
|
app.Use(sessionMiddleware)
|
||||||
|
|
9
justfile
9
justfile
|
@ -1,3 +1,6 @@
|
||||||
|
watch:
|
||||||
|
air
|
||||||
|
|
||||||
run:
|
run:
|
||||||
go run .
|
go run .
|
||||||
|
|
||||||
|
@ -15,11 +18,13 @@ fmt:
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
|
|
||||||
tidy:
|
tidy:
|
||||||
go clean -modcache
|
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
||||||
update-vendor-hash:
|
update-vendor-hash:
|
||||||
scripts/update-vendor-hash.sh
|
scripts/update-vendor-hash.sh
|
||||||
|
|
||||||
test:
|
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.SetupStatic(app)
|
||||||
roleypoly.SetupControllers(
|
roleypoly.SetupControllers(
|
||||||
app,
|
app,
|
||||||
dc,
|
roleypoly.ControllerConfig{
|
||||||
utils.DiscordPublicKey,
|
DiscordClient: dc,
|
||||||
utils.PublicBaseURL,
|
PublicKey: utils.DiscordPublicKey,
|
||||||
|
PublicBaseURL: utils.PublicBaseURL,
|
||||||
|
SupportIDs: utils.SupportIDs,
|
||||||
|
SuperuserIDs: utils.SupueruserIDs,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Fatal(app.Listen(utils.ListenAddr))
|
log.Fatal(app.Listen(utils.ListenAddr))
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
go
|
go
|
||||||
just
|
just
|
||||||
nil
|
nil
|
||||||
just
|
air
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
0
templates/tests/landing.html
Normal file
0
templates/tests/landing.html
Normal file
|
@ -1,6 +1,9 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import "os"
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
DiscordBotToken = os.Getenv("DISCORD_BOT_TOKEN")
|
DiscordBotToken = os.Getenv("DISCORD_BOT_TOKEN")
|
||||||
|
@ -9,4 +12,6 @@ var (
|
||||||
DiscordPublicKey = os.Getenv("DISCORD_PUBLIC_KEY")
|
DiscordPublicKey = os.Getenv("DISCORD_PUBLIC_KEY")
|
||||||
ListenAddr = Or(os.Getenv("LISTEN_ADDR"), ":8169")
|
ListenAddr = Or(os.Getenv("LISTEN_ADDR"), ":8169")
|
||||||
PublicBaseURL = os.Getenv("PUBLIC_BASE_URL")
|
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