Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/pottytrainer. a solution to bad poops
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657package cmd
import ( "log" "net/http"
"github.com/spf13/cobra" "twos.dev/pottytrainer/server")
const ( // AppleClientID is the environment variable key for the Apple client ID. keyAppleClientID = "APPLE_CLIENT_ID" // AppleClientSecret is the environment variable key for the Apple client // secret. keyAppleClientSecret = "APPLE_CLIENT_SECRET")
// serveCmd represents the serve command.var serveCmd = &cobra.Command{ Use: "serve", Short: wrap(`Start the API server`), Long: wrap(` Start the Potty Trainer API server to accept food and bowel movement logs. `), RunE: func(cmd *cobra.Command, args []string) error { db, err := server.NewDB(&server.DBConfig{ Region: "us-east-1", TableNamePrefix: "pottytrainer", }) if err != nil { return err }
appleClient, err := server.NewAppleClient() if err != nil { return err }
server := http.Server{ Addr: ":8080", Handler: server.RootHandler(cmd.Version, db, appleClient), }
log.Print("Starting server on :8080") if err := server.ListenAndServe(); err != nil { return err }
return nil },}
func init() { rootCmd.AddCommand(serveCmd)}