Small refactor of Episode struct and added support for Docker.

master
Michael 1 year ago
parent 01138b9cbf
commit c633aaf421

@ -0,0 +1,15 @@
FROM golang:1.20
WORKDIR $GOPATH/src/locsi/api
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN go build -v ./...
RUN go install -v ./...
EXPOSE 8080
CMD ["api"]

@ -4,7 +4,7 @@ import (
"net/http"
"github.com/gin-gonic/gin"
"locsi.com/server/models"
"locsi.com/server/api/models"
)
// GET /podcast-episode/:id

@ -4,7 +4,7 @@ import (
"net/http"
"github.com/gin-gonic/gin"
"locsi.com/server/models"
"locsi.com/server/api/models"
)
// POST /podcast-series

@ -1,4 +1,4 @@
module locsi.com/server
module locsi.com/server/api
go 1.18
@ -14,6 +14,7 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.3.0 // indirect

@ -16,8 +16,9 @@ github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVL
github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=
github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
@ -103,7 +104,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=

@ -2,8 +2,8 @@ package main
import (
"github.com/gin-gonic/gin"
"locsi.com/server/controllers"
"locsi.com/server/models"
"locsi.com/server/api/controllers"
"locsi.com/server/api/models"
)
func main() {

@ -1,10 +1,12 @@
package models
import "time"
type PodcastEpisode struct {
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
Name string `json:"name"`
ListName string `json:"list_name"`
DatePublished string `json:"date_published"`
DatePublished time.Time `json:"date_published"`
GUID string `json:"guid" desc:"Global Unique identifier of podcast." gorm:"uniqueIndex"`
Duration string `json:"duration"`
Description string `json:"description"`
ImageURL string `json:"image_url,omitempty"`

@ -1,15 +1,22 @@
package models
import "time"
type PodcastSeries struct {
ID int `json:"id,omitempty" gorm:"primaryKey;autoIncrement"`
WebFeed string `json:"web_feed" desc:"URL of RSS feed for the podcast series."`
Name string `json:"name" desc:"Title of the podcast series."`
URL string `json:"url" desc:"URL of the podcast series."`
Explicit bool `json:"explicit" desc:"Indicates if content was marked as explicit or not."`
ImageURL string `json:"image_url,omitempty" desc:"Image associated with the podcast series."`
ITunesType string `json:"itunes_type,omitempty" desc:"The value of itunes:type provided in the feed."`
InLanguage string `json:"language" desc:"The language used in the podcast series."`
GUID string `json:"guid" desc:"Global Unique identifier of podcast."`
Description string `json:"description" desc:"Description of podcast series."`
Categories []Categories `json:"categories" gorm:"many2many:podcast_categories;" desc:"Categories that the podcast series covers."`
ID int `json:"id,omitempty" gorm:"primaryKey;autoIncrement"`
WebFeed string `json:"web_feed" gorm:"uniqueIndex" desc:"URL of RSS feed for the podcast series."`
Name string `json:"name" desc:"Title of the podcast series."`
URL string `json:"url" desc:"URL of the podcast series."`
Explicit bool `json:"explicit" desc:"Indicates if content was marked as explicit or not."`
ImageURL string `json:"image_url,omitempty" desc:"Image associated with the podcast series."`
ITunesType string `json:"itunes_type,omitempty" desc:"The value of itunes:type provided in the feed."`
InLanguage string `json:"language" desc:"The language used in the podcast series."`
GUID string `json:"guid" desc:"Global Unique identifier of podcast."`
Description string `json:"description" desc:"Description of podcast series."`
WebSubHub string `json:"websub_hub" gorm:"index:,where:web_sub_hub IS NOT NULL"`
WebSubSelf string `json:"websub_self" gorm:"index:,where:web_sub_self IS NOT NULL"`
WebSubLeaseExpiration *time.Time `json:"websub_lease_expiration,omitempty" gorm:"index"`
WebSubSecret string `json:"websub_secret,omitempty" desc:"Stores the secret we expect when communicating with hubs."`
NextCrawl *time.Time `json:"next_crawl" gorm:"index" desc:"Stores the time that the feed for this podcast should be crawled again. This is only used if the podcast does not support WebSub."`
Categories []Categories `json:"categories" gorm:"many2many:podcast_categories;" desc:"Categories that the podcast series covers."`
}

@ -10,7 +10,7 @@ import (
var DB *gorm.DB
func ConnectDatabase() {
dsn := "host=" + os.Getenv("DB_HOST") + " user=" + os.Getenv("DB_USER") + " password=" + os.Getenv("DB_PASS") + " dbname=" + os.Getenv("DB_NAME") + " port=" + os.Getenv("DB_PORT") + " sslmode=disable"
dsn := os.Getenv("DSN")
database, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil {

Loading…
Cancel
Save