Created
November 14, 2020 19:40
-
-
Save cyx/70f2a818ab6b6329181edefff9ba7eac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
var cfg config | |
if err := envdecode.StrictDecode(&cfg); err != nil { | |
log.Fatal(err) | |
} | |
ctx := contextWithSignals(os.Interrupt) | |
if err := run(ctx, cfg); err != nil { | |
log.Fatal(err) | |
} | |
} | |
func run(ctx context.Context, cfg config) error { | |
db, err := sql.Open(cfg.DatabaseURL) | |
if err != nil { | |
return err | |
} | |
repository, err := postgres.NewRepository(db) | |
if err != nil { | |
return err | |
} | |
runtime, err := lambda.NewRuntime(cfg.AWS.Key, cfg.AWS.Secret) | |
if err != nil { | |
return err | |
} | |
server := &api.Server{ | |
Repository: repository, | |
Runtime: runtime, | |
} | |
return server.Run() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment