Files
authorizer/server/main.go

57 lines
1.6 KiB
Go
Raw Normal View History

package main
import (
"flag"
"github.com/authorizerdev/authorizer/server/constants"
2021-07-28 11:53:37 +05:30
"github.com/authorizerdev/authorizer/server/db"
2021-12-20 17:33:11 +05:30
"github.com/authorizerdev/authorizer/server/env"
2021-07-23 21:57:44 +05:30
"github.com/authorizerdev/authorizer/server/handlers"
"github.com/authorizerdev/authorizer/server/oauth"
2021-12-22 15:31:45 +05:30
"github.com/authorizerdev/authorizer/server/router"
2021-07-28 11:53:37 +05:30
"github.com/authorizerdev/authorizer/server/session"
"github.com/authorizerdev/authorizer/server/utils"
)
2021-12-24 17:47:35 +05:30
var VERSION string
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-31 13:52:10 +05:30
constants.EnvData.VERSION = VERSION
2021-12-24 17:47:35 +05:30
2021-12-20 17:33:11 +05:30
env.InitEnv()
2021-07-28 11:53:37 +05:30
db.InitDB()
2021-12-31 13:52:10 +05:30
env.PersistEnv()
2021-07-28 11:53:37 +05:30
session.InitSession()
oauth.InitOAuth()
utils.InitServer()
2021-07-28 11:53:37 +05:30
2021-12-22 15:31:45 +05:30
router := router.InitRouter()
router.LoadHTMLGlob("templates/*")
// login page app related routes.
// if we put them in router file then tests would fail as templates or build path will be different
2021-12-31 13:52:10 +05:30
if !constants.EnvData.DISABLE_LOGIN_PAGE {
app := router.Group("/app")
{
app.Static("/build", "app/build")
app.GET("/", handlers.AppHandler())
app.GET("/reset-password", handlers.AppHandler())
}
}
app := router.Group("/dashboard")
{
app.Static("/build", "dashboard/build")
app.GET("/", handlers.DashboardHandler())
}
2021-12-31 13:52:10 +05:30
router.Run(":" + constants.EnvData.PORT)
}