Skip to content

Instantly share code, notes, and snippets.

@cyx
Created November 14, 2020 19:40
Show Gist options
  • Save cyx/70f2a818ab6b6329181edefff9ba7eac to your computer and use it in GitHub Desktop.
Save cyx/70f2a818ab6b6329181edefff9ba7eac to your computer and use it in GitHub Desktop.
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