- Revise folder sturcture and align everything without touching module names. Make sure everything is singular. Think about contexts. Don't forget about tests.
- Rename modules to match their file system path
- Refactor domain APIs to return {:ok, error} tuples, remove all error formatting from it
- Introduce fallback controller
- Go over all modules again and make sure naming is correct
- Remove all Elixir 1.5 and other warnings
- Bump deps and repeat
This file contains hidden or 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
defmodule MyAppAPI.ReleaseTasks do | |
alias Ecto.Migrator | |
@otp_app :myapp_api | |
@start_apps [:logger, :ssl, :postgrex, :ecto] | |
def migrate do | |
init(@otp_app, @start_apps) | |
run_migrations_for(@otp_app) |
This file contains hidden or 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
defmodule MyAppAPI.Changeset do | |
import Ecto.Changeset | |
@known_buckets Application.get_env(:myapp_api, :known_buckets) | |
# ... | |
def changeset(schema, attrs) do | |
schema | |
|> cast(attrs, @fields) |
This file contains hidden or 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
defmodule MyAppAPI.Changeset do | |
import Ecto.Changeset | |
@on_load :load_buckets | |
# ... | |
def load_buckets do | |
known_buckets = "KNOWN_BUCKETS" |> System.get_env() |> String.split(",", trim: true) | |
Application.put_env(:myapp_api, :known_buckets, known_buckets) |
This file contains hidden or 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
defmodule MyAppAPI.Endpoint do | |
use Phoenix.Endpoint, otp_app: :myapp_api | |
# ... | |
@doc """ | |
Callback invoked for dynamically configuring the endpoint. | |
It receives the endpoint configuration and checks if | |
configuration should be loaded from the system environment. | |
""" |
This file contains hidden or 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
defmodule MyAppAPI.Repo do | |
use Ecto.Repo, otp_app: :myapp_api | |
def init(_type, config) do | |
url = System.get_env("DATABASE_URL") | |
if url, do: {:ok, [url: url] ++ config}, else: {:ok, config} | |
end | |
end |
This file contains hidden or 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
config :myapp_api, :third_party_lib, | |
cloud_name: "${CLOUDINARY_CLOUD_NAME}", | |
bucket_name: "${CLOUDINARY_BUCKET_NAME}", | |
bucket_region: "${CLOUDINARY_BUCKET_REGION}", | |
frontend_url: "${FRONTEND_URL}" |
This file contains hidden or 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
use Mix.Releases.Config, | |
# This sets the default release built by `mix release` | |
default_release: :default, | |
# This sets the default environment used by `mix release` | |
default_environment: :default | |
environment :default do | |
# Copy files into release instead of creating symlink for them | |
set dev_mode: false | |
# Do not include ERTS |
This file contains hidden or 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
defmodule Ael.Secrets.API do | |
def get_secret_url(secret) do | |
%Secret{ | |
action: action, | |
expires_at: expires_at, | |
bucket: bucket, | |
resource_id: resource_id, | |
resource_name: resource_name | |
} = secret |
I hereby claim:
- I am andrewdryga on github.
- I am andrewdryga (https://keybase.io/andrewdryga) on keybase.
- I have a public key ASCO83B78ctJpdof-fS5nIL6Gdvlenz5NAZvWbbgbKmhJAo
To claim this, I am signing this object: