go fmt, add some basic tests for postal api info
This commit is contained in:
parent
f0799e0adb
commit
198fd10bf0
5 changed files with 21 additions and 4 deletions
3
main.go
3
main.go
|
@ -31,6 +31,9 @@ func main() {
|
|||
users.TokenAuth = auth.TokenAuth
|
||||
blog.TokenAuth = auth.TokenAuth
|
||||
|
||||
// initilize auth
|
||||
auth.Init()
|
||||
|
||||
// initiate the routes
|
||||
router := Routes()
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/go-chi/render"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
@ -20,8 +21,21 @@ import (
|
|||
var (
|
||||
DB *sql.DB
|
||||
TokenAuth *jwtauth.JWTAuth
|
||||
PostalEnabled bool
|
||||
PostalKey string
|
||||
PostalAPI string
|
||||
)
|
||||
|
||||
func Init() {
|
||||
if postal_key, ok := os.LookupEnv("POSTAL_KEY"); ok {
|
||||
PostalKey = postal_key
|
||||
if postal_api, ok := os.LookupEnv("POSTAL_API"); ok {
|
||||
PostalAPI = postal_api
|
||||
PostalEnabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type ReturnError struct {
|
||||
Message string `json:"error"`
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ type ReferenceID struct {
|
|||
LastID int `json:"last_id"`
|
||||
}
|
||||
|
||||
|
||||
func Routes() *chi.Mux {
|
||||
r := chi.NewRouter()
|
||||
r.Group(func(r chi.Router) {
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
export DB_PW="CHANGEME"
|
||||
export POSTAL_API="POSTAL_API_KEY"
|
||||
export POSTAL_KEY="POSTAL_API_KEY"
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
export API_PORT="8080"
|
||||
export JWT_SECRET="CHANGEMEALSO"
|
||||
export POSTAL_API="https://POSTAL_URL"
|
||||
|
|
Reference in a new issue