Fix Formatting
This commit is contained in:
parent
b05b1eb9b6
commit
3fd6e7b957
@ -45,8 +45,8 @@ func cmdServer(ctx *cli.Context) error {
|
|||||||
server.StartServer()
|
server.StartServer()
|
||||||
|
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, os.Interrupt)
|
signal.Notify(c, os.Interrupt)
|
||||||
<-c
|
<-c
|
||||||
|
|
||||||
server.StopServer()
|
server.StopServer()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -12,9 +12,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
API *api.API
|
API *api.API
|
||||||
Auth *auth.AuthManager
|
Auth *auth.AuthManager
|
||||||
Config *config.Config
|
Config *config.Config
|
||||||
Database *db.DBManager
|
Database *db.DBManager
|
||||||
httpServer *http.Server
|
httpServer *http.Server
|
||||||
}
|
}
|
||||||
@ -45,8 +45,8 @@ func (s *Server) StartServer() {
|
|||||||
err := s.httpServer.ListenAndServe()
|
err := s.httpServer.ListenAndServe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error starting server ", err)
|
log.Error("Error starting server ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/lestrrat-go/jwx/jwt"
|
"github.com/lestrrat-go/jwx/jwt"
|
||||||
|
|
||||||
"reichard.io/imagini/internal/models"
|
"reichard.io/imagini/internal/models"
|
||||||
)
|
)
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
"errors"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gorm.io/gorm"
|
"github.com/lestrrat-go/jwx/jwa"
|
||||||
"reichard.io/imagini/internal/db"
|
"github.com/lestrrat-go/jwx/jwt"
|
||||||
"reichard.io/imagini/internal/config"
|
|
||||||
"reichard.io/imagini/internal/models"
|
|
||||||
"reichard.io/imagini/internal/session"
|
|
||||||
|
|
||||||
"encoding/json"
|
"reichard.io/imagini/internal/db"
|
||||||
"fmt"
|
"reichard.io/imagini/internal/config"
|
||||||
"time"
|
"reichard.io/imagini/internal/models"
|
||||||
|
"reichard.io/imagini/internal/session"
|
||||||
"github.com/lestrrat-go/jwx/jwa"
|
|
||||||
"github.com/lestrrat-go/jwx/jwt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthManager struct {
|
type AuthManager struct {
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
// "gorm.io/gorm/logger"
|
// "gorm.io/gorm/logger"
|
||||||
"gorm.io/driver/sqlite"
|
"gorm.io/driver/sqlite"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"reichard.io/imagini/internal/config"
|
"reichard.io/imagini/internal/config"
|
||||||
"reichard.io/imagini/internal/models"
|
"reichard.io/imagini/internal/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DBManager struct {
|
type DBManager struct {
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"reichard.io/imagini/internal/models"
|
"reichard.io/imagini/internal/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (dbm *DBManager) CreateDevice(device models.Device) (models.Device, error) {
|
func (dbm *DBManager) CreateDevice(device models.Device) (models.Device, error) {
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"reichard.io/imagini/internal/models"
|
"reichard.io/imagini/internal/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (dbm *DBManager) CreateUser(user models.User) (models.User, error) {
|
func (dbm *DBManager) CreateUser(user models.User) (models.User, error) {
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/uuid"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
"time"
|
"time"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Base contains common columns for all tables.
|
// Base contains common columns for all tables.
|
||||||
type Base struct {
|
type Base struct {
|
||||||
UUID uuid.UUID `gorm:"type:uuid;primarykey"`
|
UUID uuid.UUID `gorm:"type:uuid;primarykey"`
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (base *Base) BeforeCreate(tx *gorm.DB) (err error) {
|
func (base *Base) BeforeCreate(tx *gorm.DB) (err error) {
|
||||||
|
@ -31,8 +31,8 @@ func (sm *SessionManager) Delete(key string) {
|
|||||||
sm.mutex.Lock()
|
sm.mutex.Lock()
|
||||||
defer sm.mutex.Unlock()
|
defer sm.mutex.Unlock()
|
||||||
_, exists := sm.values[key]
|
_, exists := sm.values[key]
|
||||||
if !exists {
|
if !exists {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
delete(sm.values, key)
|
delete(sm.values, key)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user