Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dhax committed Oct 4, 2023
1 parent 09eeccd commit 8be7e5c
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 384 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
.realize.yaml
.idea

.env
.env.*
!.env.example

debug
go-base

Expand All @@ -16,4 +20,4 @@ go-base
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.out
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ The following feature set is a minimal selection of typical Web API requirements

## Start Application

- Clone this repository
- Create a postgres database and set environment variables for your database accordingly if not using same as default
- Clone and change into this repository

### Local

- Create a postgres database and set environment variables for your database accordingly if not using below defaults
- Run the application to see available commands: `go run main.go`
- First initialize the database running all migrations found in ./database/migrate at once with command _migrate_: `go run main.go migrate`
- Run all migrations from database/migrate folder: `go run main.go migrate`
- Run the application with command _serve_: `go run main.go serve`

Or just use the provided docker-compose file. After first start attach to the server container and run `./main migrate` to populate the database.
### Using Docker Compose

- First start the database only: `docker compose up -d postgres`
- Once initialize the database by running all migrations in database/migrate folder: `docker compose exec server ./main migrate`
- Start the api server: `docker compose up server`

## API Routes

Expand Down Expand Up @@ -69,6 +76,10 @@ Use one of the following bootstrapped users for login:

A deployed version can also be found on [Heroku](https://govue.herokuapp.com)

### Testing

Package auth/pwdless contains example api tests using a mocked database. Run them with: `go test -v ./...`

### Environment Variables

By default viper will look at $HOME/.go-base.yaml for a config file. Setting your config as Environment Variables is recommended as by 12-Factor App.
Expand Down Expand Up @@ -97,10 +108,6 @@ By default viper will look at $HOME/.go-base.yaml for a config file. Setting you
| EMAIL_FROM_NAME | string | | from name used in sending emails |
| ENABLE_CORS | bool | false | enable CORS requests |

### Testing

Package auth/pwdless contains example api tests using a mocked database.

[godoc]: https://godoc.org/github.com/dhax/go-base
[godoc badge]: https://godoc.org/github.com/dhax/go-base?status.svg
[goreportcard]: https://goreportcard.com/report/github.com/dhax/go-base
Expand Down
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func New(enableCORS bool) (*chi.Mux, error) {
r.Mount("/api", appAPI.Router())
})

r.Get("/ping", func(w http.ResponseWriter, r *http.Request) {
r.Get("/ping", func(w http.ResponseWriter, _ *http.Request) {
w.Write([]byte("pong"))
})

Expand Down
2 changes: 1 addition & 1 deletion auth/jwt/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"net/http"

"github.com/lestrrat-go/jwx/jwt"
"github.com/lestrrat-go/jwx/v2/jwt"

"github.com/go-chi/jwtauth/v5"
"github.com/go-chi/render"
Expand Down
2 changes: 1 addition & 1 deletion auth/jwt/claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jwt
import (
"errors"

"github.com/lestrrat-go/jwx/jwt"
"github.com/lestrrat-go/jwx/v2/jwt"
)

type CommonClaims struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/gendoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cmd

import (
"fmt"
"io/ioutil"
"log"
"os"

"github.com/dhax/go-base/api"
"github.com/go-chi/docgen"
Expand Down Expand Up @@ -53,7 +53,7 @@ func genRoutesDoc() {
ProjectPath: "github.com/dhax/go-base",
Intro: "GoBase REST API.",
})
if err := ioutil.WriteFile("routes.md", []byte(md), 0644); err != nil {
if err := os.WriteFile("routes.md", []byte(md), 0644); err != nil {
log.Println(err)
return
}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ services:
ENABLE_CORS: "true"

postgres:
image: postgres:13
image: postgres:16
restart: unless-stopped
ports:
- 5432:5432
volumes:
- postgres:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_PASSWORD: postgres
107 changes: 54 additions & 53 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,66 +1,67 @@
module github.com/dhax/go-base

go 1.18

require (
github.com/PuerkitoBio/goquery v1.4.1 // indirect
github.com/andybalholm/cascadia v1.0.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf // indirect
github.com/go-chi/chi/v5 v5.0.4
github.com/go-chi/cors v1.2.0
github.com/go-chi/chi/v5 v5.0.10
github.com/go-chi/cors v1.2.1
github.com/go-chi/docgen v1.2.0
github.com/go-chi/jwtauth/v5 v5.0.1
github.com/go-chi/render v1.0.1
github.com/go-chi/jwtauth/v5 v5.1.1
github.com/go-chi/render v1.0.3
github.com/go-mail/mail v2.3.1+incompatible
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible
github.com/go-pg/migrations v6.2.0+incompatible
github.com/go-pg/pg v7.1.7+incompatible
github.com/gofrs/uuid v3.2.0+incompatible
github.com/gorilla/css v1.0.0 // indirect
github.com/jaytaylor/html2text v0.0.0-20200220170450-61d9dc4d7195
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect
github.com/lestrrat-go/jwx v1.2.11
github.com/mattn/go-runewidth v0.0.8 // indirect
github.com/go-pg/migrations v6.7.3+incompatible
github.com/go-pg/pg v8.0.7+incompatible
github.com/gofrs/uuid v4.4.0+incompatible
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056
github.com/lestrrat-go/jwx/v2 v2.0.13
github.com/mitchellh/go-homedir v1.1.0
github.com/mssola/user_agent v0.5.1
github.com/olekukonko/tablewriter v0.0.4 // indirect
github.com/onsi/gomega v1.4.2 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v0.0.6
github.com/mssola/user_agent v0.6.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
github.com/vanng822/go-premailer v1.20.2
)

require (
github.com/PuerkitoBio/goquery v1.5.1 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/andybalholm/cascadia v1.1.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.4 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.28.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.8.1
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
github.com/vanng822/css v0.0.0-20190504095207-a21e860bcd04 // indirect
github.com/vanng822/go-premailer v0.0.0-20191214114701-be27abe028fe
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/text v0.3.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/vanng822/css v1.0.1 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/mail.v2 v2.3.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
mellium.im/sasl v0.2.1 // indirect
)

require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/goccy/go-json v0.7.10 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.0 // indirect
github.com/lestrrat-go/httpcc v1.0.0 // indirect
github.com/lestrrat-go/iter v1.0.1 // indirect
github.com/lestrrat-go/option v1.0.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/onsi/ginkgo v1.6.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/crypto v0.0.0-20201217014255-9d1352758620 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
mellium.im/sasl v0.3.1 // indirect
)

go 1.17
Loading

0 comments on commit 8be7e5c

Please sign in to comment.