authorizer/server/main.go

42 lines
1.3 KiB
Go
Raw Normal View History

package main
import (
"flag"
"github.com/authorizerdev/authorizer/server/constants"
2021-07-28 06:23:37 +00:00
"github.com/authorizerdev/authorizer/server/db"
2021-12-20 12:03:11 +00:00
"github.com/authorizerdev/authorizer/server/env"
2021-07-23 16:27:44 +00:00
"github.com/authorizerdev/authorizer/server/handlers"
"github.com/authorizerdev/authorizer/server/oauth"
2021-12-22 10:01:45 +00:00
"github.com/authorizerdev/authorizer/server/router"
2021-07-28 06:23:37 +00:00
"github.com/authorizerdev/authorizer/server/session"
"github.com/authorizerdev/authorizer/server/utils"
)
func main() {
env.ARG_DB_URL = flag.String("database_url", "", "Database connection string")
env.ARG_DB_TYPE = flag.String("database_type", "", "Database type, possible values are postgres,mysql,sqlite")
env.ARG_AUTHORIZER_URL = flag.String("authorizer_url", "", "URL for authorizer instance, eg: https://xyz.herokuapp.com")
env.ARG_ENV_FILE = flag.String("env_file", "", "Env file path")
flag.Parse()
2021-12-20 12:03:11 +00:00
env.InitEnv()
2021-07-28 06:23:37 +00:00
db.InitDB()
session.InitSession()
oauth.InitOAuth()
utils.InitServer()
2021-07-28 06:23:37 +00:00
2021-12-22 10:01:45 +00:00
router := router.InitRouter()
// login wall app related routes.
// if we put them in router file then tests would fail as templates or build path will be different
2021-12-22 10:01:45 +00:00
router.LoadHTMLGlob("templates/*")
app := router.Group("/app")
{
app.Static("/build", "app/build")
app.GET("/", handlers.AppHandler())
app.GET("/reset-password", handlers.AppHandler())
}
2021-12-22 10:01:45 +00:00
router.Run(":" + constants.PORT)
}