Skip to content

oppa-archive/cloudfunction-backend

Repository files navigation

API Template

Style Guide

We mostly follow Uber Style Guide.

Architecture & code organization

Note: would change over time.

.
├── template.yaml              # AWS SAM Template
├── Makefile                   # Makefile
├── handlers                   # Main application commands & entry point
│   └── <lambda-name>          # Contains 'main.go' lambda handler
├── migrations                 # Database migrations
├── models                     # database entities (including their specific enum interfaces)
├── repositories               # database access layer
├── config                     # configurations and env variable/setup
└── pkg                        # 3rd party lib wrappers and/or utility functions. (Utilities should be extracted)
    ├── utils                  # utility library.
    └── db                     # database library.
        └── migrations         # utilities for database migrations

NOTE: 'dev' instances of database are used for Local Development.

Requirements

You may need the following for local testing.

Install the CLI tools and Docker CE

brew install watchexec

Testing

We use testing package that is built-in in Golang and you can simply run the following command to run our tests locally:

go test -v ./handlers/<lambda-name>/

Engineering Practices

  • Code defensively: never make assumption about the data in the database or api response.
  • Data Duplication, denormalizing data: document stores are allowed to denormalize data.
    • Duplicated data changes can be enforced.

Releases

No releases published

Packages

No packages published