38 lines
801 B
Go
38 lines
801 B
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
auth "nyanimedb/auth"
|
|
handlers "nyanimedb/modules/auth/handlers"
|
|
sqlc "nyanimedb/sql"
|
|
|
|
"github.com/gin-contrib/cors"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
var AppConfig Config
|
|
|
|
func main() {
|
|
r := gin.Default()
|
|
|
|
var queries *sqlc.Queries = nil
|
|
|
|
server := handlers.NewServer(queries)
|
|
|
|
r.Use(cors.New(cors.Config{
|
|
AllowOrigins: []string{"*"}, // allow all origins, change to specific domains in production
|
|
AllowMethods: []string{"GET", "POST", "PUT", "DELETE"},
|
|
AllowHeaders: []string{"Origin", "Content-Type", "Accept"},
|
|
ExposeHeaders: []string{"Content-Length"},
|
|
AllowCredentials: true,
|
|
MaxAge: 12 * time.Hour,
|
|
}))
|
|
|
|
auth.RegisterHandlers(r, auth.NewStrictHandler(
|
|
server,
|
|
[]auth.StrictMiddlewareFunc{},
|
|
))
|
|
|
|
r.Run(":8082")
|
|
}
|