// SetupBuckets adds the given db.Buckets to the DB. func SetupBuckets(buckets ...[]db.Bucket) SetupFunc { return func(t *DB) error { for _, bs := range buckets { if err := db.SetupBuckets(t, bs); err != nil { return err } } return nil } }
func SetupBuckets(buckets ...[]db.Bucket) setupFunc { return func(t *TestingDB) error { for _, bs := range buckets { err := db.SetupBuckets(t, bs) if err != nil { return err } } return nil } }
func Admin(d db.DB) API { return func(r *htr.Router) error { if err := db.SetupBuckets(d, admin.Buckets()); err != nil { return err } r.GET("/admin/valid", handleAdminValid(d)) r.GET("/admin/create", handleAdminCreate(d)) r.GET("/admin/delete", handleAdminDelete(d)) return nil } }
func User(d db.DB) API { return func(r *htr.Router) error { if err := db.SetupBuckets(d, user.Buckets()); err != nil { return err } r.GET("/user/create", handleUserCreate(d)) r.GET("/user/delete", handleUserDelete(d)) r.GET("/user/valid", handleUserValid(d)) r.GET("/user/login", handleUserLogin(d)) r.GET("/user/logout", handleUserLogout(d)) return nil } }
func Auth(d db.DB) API { return func(r *htr.Router) error { err := db.SetupBuckets(d, auth.Buckets()) if err != nil { return err } r.GET("/user/create", handleCreate(d)) r.GET("/user/delete", handleDelete(d)) r.GET("/user/valid", handleValid(d)) r.GET("/user/login", handleLogin(d)) r.GET("/user/logout", handleLogout(d)) return nil } }
func AdminCLI(d db.DB) cli.Binding { return func(c *cli.CLI) error { if err := db.SetupBuckets(d, admin.Buckets()); err != nil { return err } return c.AddCommands(&cli.Command{ Name: "create", Description: "create a new admin", Aliases: []string{"c", "admin", "new"}, Fn: cliCreate(c, d), }, &cli.Command{ Name: "delete", Description: "delete an admin by email", Aliases: []string{"d", "kill"}, Fn: cliDelete(d), }) } }