+ updated readme and no more .env files

This commit is contained in:
Itsigo
2025-11-12 15:56:28 +01:00
parent b3193a10f9
commit 5467ddcbba
7 changed files with 65 additions and 18 deletions

View File

@@ -6,16 +6,17 @@ import (
"io"
"net/http"
"net/url"
"os"
_ "github.com/joho/godotenv/autoload"
)
var (
token = os.Getenv("TMDB_API_KEY")
apiurl = "https://api.themoviedb.org/3/"
token = ""
)
func Init(apitoken string) {
token = apitoken
}
func request(requrl string) (*http.Response, []byte) {
req, _ := http.NewRequest("GET", apiurl+requrl, nil)

View File

@@ -15,11 +15,17 @@ import (
"git.itsigo.dev/istigo/pocketmovie/internal/middleware/apikeychecker"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/log"
"github.com/gofiber/fiber/v3/middleware/compress"
"github.com/gofiber/fiber/v3/middleware/static"
)
func (s *FiberServer) RegisterFiberRoutes() {
s.App.Use("/apikey", s.apikeyinput)
s.App.Use(
compress.New(compress.Config{
Level: compress.LevelBestSpeed, // 1
}),
)
s.App.Use("/assets", static.New("./assets", static.Config{
FS: web.Files,
@@ -28,6 +34,8 @@ func (s *FiberServer) RegisterFiberRoutes() {
s.App.Use("/movie/posters", static.New("./data/img"))
s.App.Use("/apikey", s.apikeyinput)
s.App.Use(
//basicauth.New(basicauth.Config{
// Users: map[string]string{
@@ -35,9 +43,6 @@ func (s *FiberServer) RegisterFiberRoutes() {
// "john": "{SHA256}eZ75KhGvkY4/t0HfQpNPO1aO0tk6wd908bjUGieTKm8=",
// },
//}),
//compress.New(compress.Config{
// Level: compress.LevelBestSpeed, // 1
//}),
apikeychecker.New(apikeychecker.Config{DB: *s.db}),
)

View File

@@ -11,13 +11,13 @@ type FiberServer struct {
db *database.Queries
}
func New() *FiberServer {
func New(db *database.Queries) *FiberServer {
server := &FiberServer{
App: fiber.New(fiber.Config{
ServerHeader: "PocketMovie",
AppName: "PocketMovie",
}),
db: database.Init(),
db: db,
}
return server
}