Browse Source

Started working on the storage system

main
Artemis 2 months ago
parent
commit
3a79ea8c48
  1. 3
      .gitmodules
  2. 0
      internal/app/core.go
  3. 5
      internal/config/core.go
  4. 0
      internal/log/core.go
  5. 6
      internal/storage/core.go
  6. 2
      web/route.go
  7. 9
      web/uploads.go
  8. 1
      wiki

3
.gitmodules

@ -0,0 +1,3 @@
[submodule "wiki"]
path = wiki
url = gitea@git.aphrodite.dev:ArtemisNeko/gallery.wiki.git

0
internal/app/cli.go → internal/app/core.go

5
internal/config/config.go → internal/config/core.go

@ -21,9 +21,8 @@ const (
)
type Config struct {
ListenAddress string `fig:"listen"`
DbPath string `fig:"db" default:"gallery.db"`
VerboseLogging bool `fig:"verbose"`
ListenAddress string `fig:"listen"`
DbPath string `fig:"db" default:"gallery.db"`
}
func GetConfig(directPath string) (*Config, error) {

0
internal/log/log.go → internal/log/core.go

6
internal/storage/core.go

@ -0,0 +1,6 @@
package storage
type Storage interface {
// TODO: Interface or struct? Depends on my laziness. Probably a struct for the main selector and
// then interface/structs. Because I def want to support S3 for myself
}

2
web/route.go

@ -18,7 +18,7 @@ type Handlers struct {
func (h Handlers) SetupRouter(r *bunrouter.Router) {
for prefix, module := range map[string]Module{
"/test": TempHandlers{config: &h.Config, db: &h.Db},
"/@me": UploadsHandlers{config: &h.Config, db: &h.Db},
"/dashboard": UploadsHandlers{config: &h.Config, db: &h.Db},
} {
module.Apply(r.NewGroup(prefix))
}

9
web/uploads.go

@ -3,7 +3,9 @@ package web
import (
"git.artemix.space/go/gallery/internal/config"
"git.artemix.space/go/gallery/internal/db"
"git.artemix.space/go/gallery/internal/log"
"github.com/uptrace/bunrouter"
"go.uber.org/zap"
"net/http"
)
@ -17,5 +19,12 @@ func (h UploadsHandlers) Apply(r *bunrouter.Group) {
}
func (h UploadsHandlers) UploadsDashboard(w http.ResponseWriter, req bunrouter.Request) error {
imageCount, err := h.db.GetDB().NewSelect().Model((*db.Image)(nil)).Count(req.Context())
if err != nil {
return err
}
log.L.Info("got images", zap.Int("count", imageCount))
return nil
}

1
wiki

@ -0,0 +1 @@
Subproject commit 488aaf95595b4adc72edda78ed9c3e9b9afdabb9
Loading…
Cancel
Save