Exemple #1
0
func main() {
	var (
		listen = flag.String("listen", ":3000", "listen address of the application")
		env    = flag.String("env", "dev", "application environment")
	)
	flag.Parse()

	// set the flags into env vars
	os.Setenv("APP_ENV", *env)

	// initialize database connection, with the credentials from the environment.
	repo, err := database.Connect()
	if err != nil {
		panic(err)
	}

	// repo configuration
	repo.LogMode(true)

	// application configuration
	router := echo.New()
	router.SetHTTPErrorHandler(errorHandler)

	router.Use(middleware.Logger(), middleware.Recover())

	registerAuthHandlers(router, handler.AuthService{})

	// V1 API endpoints
	v1 := router.Group("/v1")
	registerUserHandlers(v1, handler.UserService{repo})

	router.Run(*listen)
}
Exemple #2
0
func main() {
	repo, err := database.Connect()
	if err != nil {
		panic(err)
	}
	repo.LogMode(true)

	for _, user := range users {
		user.SetPassword(user.Password)
		repo.Create(&user)
	}

}