2025-08-06 18:17:50 +02:00

38 lines
631 B
Go

package main
import (
"fmt"
"git.tijl.dev/tijl/shortify"
"git.tijl.dev/tijl/shortify/pkg/generation"
"github.com/gofiber/fiber/v2"
)
func main() {
s, err := shortify.New(shortify.Config{
DataFolder: "./shortify",
})
if err != nil {
panic(err)
}
// example decoding
fmt.Println(generation.DecodeBase62("11uPoqA1W"))
// listen the admin interface
unixListener, err := shortify.GetUnixListener("./shortify/admin.sock")
go s.Admin().Listener(unixListener)
// listen the interface for normies
a := fiber.New()
a.Post("/shorten", s.HandlePostURL())
a.Get("/s/:id", s.HandleGetURL())
a.Listen(":3001")
}