Skip to content

Commit

Permalink
again
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperninjaXII committed Nov 6, 2024
1 parent a486f87 commit d49b356
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions api/index.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// /api/index.go

package handler

import (
"log"
"net/http"
"search/config"
"search/routes"
Expand All @@ -11,28 +10,34 @@ import (
"github.com/gofiber/template/html/v2"
)

// Handler function expected by Vercel
func Handler(w http.ResponseWriter, r *http.Request) {
// Log to stdout (will be visible in Vercel logs)
log.Println("Starting Fiber app...")

// Initialize the Fiber engine
engine := html.New("./../views", ".html")
engine := html.New("./views", ".html")

// Create a new Fiber app
app := fiber.New(fiber.Config{
Views: engine, // Set the template engine
})

// Serve static files
app.Static("/", "./../public")
app.Static("/", "./public")

// Define routes
routes.Routes(app)

// Log the fact that we are listening on a port
log.Println("App is listening on :3000")

// Handle HTTP requests with Fiber
app.Listener = http.NewServeMux()
app.Listener.ServeHTTP(w, r)
}

func init() {
// Initialize the database before running the app
log.Println("Initializing database...")
config.Database()
}

0 comments on commit d49b356

Please sign in to comment.