authorizer/server/main.go

44 lines
1.3 KiB
Go
Raw Normal View History

package main
import (
"flag"
2022-02-26 04:14:55 +00:00
"log"
"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"
2022-01-17 06:02:13 +00:00
"github.com/authorizerdev/authorizer/server/envstore"
2021-07-23 16:27:44 +00:00
"github.com/authorizerdev/authorizer/server/oauth"
2022-01-17 06:02:13 +00:00
"github.com/authorizerdev/authorizer/server/routes"
"github.com/authorizerdev/authorizer/server/sessionstore"
)
2021-12-24 12:17:35 +00:00
var VERSION string
func main() {
envstore.ARG_DB_URL = flag.String("database_url", "", "Database connection string")
envstore.ARG_DB_TYPE = flag.String("database_type", "", "Database type, possible values are postgres,mysql,sqlite")
envstore.ARG_ENV_FILE = flag.String("env_file", "", "Env file path")
flag.Parse()
envstore.EnvInMemoryStoreObj.UpdateEnvVariable(constants.StringStoreIdentifier, constants.EnvKeyVersion, VERSION)
2021-12-24 12:17:35 +00:00
2022-02-26 04:14:55 +00:00
// initialize required envs (mainly db env & env file path)
env.InitRequiredEnv()
// initialize db provider
2021-07-28 06:23:37 +00:00
db.InitDB()
2022-02-26 04:14:55 +00:00
// initialize all envs
env.InitAllEnv()
// persist all envs
err := env.PersistEnv()
if err != nil {
log.Println("Error persisting env:", err)
}
2021-12-31 08:22:10 +00:00
sessionstore.InitSession()
oauth.InitOAuth()
2022-01-17 06:02:13 +00:00
router := routes.InitRouter()
router.Run(":" + envstore.EnvInMemoryStoreObj.GetStringStoreEnvVariable(constants.EnvKeyPort))
}