Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 32 additions & 23 deletions .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
#
{Credo.Check.Consistency.ExceptionNames, []},
{Credo.Check.Consistency.LineEndings, []},
{Credo.Check.Consistency.ParameterPatternMatching, []},
{Credo.Check.Consistency.SpaceAroundOperators, []},
{Credo.Check.Consistency.SpaceInParentheses, []},
{Credo.Check.Consistency.TabsOrSpaces, []},
Expand All @@ -81,7 +80,6 @@
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage, false},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
Expand All @@ -92,40 +90,26 @@
#
## Readability Checks
#
{Credo.Check.Readability.AliasOrder, []},
{Credo.Check.Readability.FunctionNames, []},
{Credo.Check.Readability.LargeNumbers, []},
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
{Credo.Check.Readability.ModuleAttributeNames, []},
{Credo.Check.Readability.ModuleDoc, []},
{Credo.Check.Readability.ModuleNames, []},
{Credo.Check.Readability.ParenthesesInCondition, []},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
{Credo.Check.Readability.PredicateFunctionNames, []},
{Credo.Check.Readability.PreferImplicitTry, []},
{Credo.Check.Readability.RedundantBlankLines, []},
{Credo.Check.Readability.Semicolons, []},
{Credo.Check.Readability.SpaceAfterCommas, []},
{Credo.Check.Readability.StringSigils, []},
{Credo.Check.Readability.TrailingBlankLine, []},
{Credo.Check.Readability.TrailingWhiteSpace, []},
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
{Credo.Check.Readability.VariableNames, []},

#
## Refactoring Opportunities
#
{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.CyclomaticComplexity, []},
{Credo.Check.Refactor.FunctionArity, []},
{Credo.Check.Refactor.LongQuoteBlocks, []},
# {Credo.Check.Refactor.MapInto, []},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.UnlessWithElse, []},
{Credo.Check.Refactor.WithClauses, []},

#
## Warnings
Expand Down Expand Up @@ -156,32 +140,57 @@
#
# Controversial and experimental checks (opt-in, just replace `false` with `[]`)
#
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
{Credo.Check.Consistency.UnusedVariableNames, false},
{Credo.Check.Design.DuplicatedCode, false},
{Credo.Check.Readability.AliasAs, false},
{Credo.Check.Readability.BlockPipe, false},
{Credo.Check.Readability.ImplTrue, false},
{Credo.Check.Readability.MultiAlias, false},
{Credo.Check.Readability.SeparateAliasRequire, false},
{Credo.Check.Readability.SinglePipe, false},
{Credo.Check.Readability.Specs, false},
{Credo.Check.Readability.StrictModuleLayout, false},
{Credo.Check.Readability.WithCustomTaggedTuple, false},
{Credo.Check.Refactor.ABCSize, false},
{Credo.Check.Refactor.AppendSingleItem, false},
{Credo.Check.Refactor.DoubleBooleanNegation, false},
{Credo.Check.Refactor.ModuleDependencies, false},
{Credo.Check.Refactor.NegatedIsNil, false},
{Credo.Check.Refactor.PipeChainStart, false},
{Credo.Check.Refactor.VariableRebinding, false},
{Credo.Check.Warning.LeakyEnvironment, false},
{Credo.Check.Warning.MapGetUnsafePass, false},
{Credo.Check.Warning.UnsafeToAtom, false}
{Credo.Check.Warning.UnsafeToAtom, false},

#
# Custom checks can be created using `mix credo.gen.check`.
#

# Disable rules enforced by Styler
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
{Credo.Check.Consistency.ParameterPatternMatching, false},
{Credo.Check.Design.AliasUsage, false},
{Credo.Check.Readability.AliasOrder, false},
{Credo.Check.Readability.BlockPipe, false},
{Credo.Check.Readability.LargeNumbers, false},
{Credo.Check.Readability.ModuleDoc, false},
{Credo.Check.Readability.MultiAlias, false},
{Credo.Check.Readability.OneArityFunctionInPipe, false},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, false},
{Credo.Check.Readability.PipeIntoAnonymousFunctions, false},
{Credo.Check.Readability.PreferImplicitTry, false},
{Credo.Check.Readability.SinglePipe, false},
{Credo.Check.Readability.StrictModuleLayout, false},
{Credo.Check.Readability.StringSigils, false},
{Credo.Check.Readability.UnnecessaryAliasExpansion, false},
{Credo.Check.Readability.WithSingleClause, false},
{Credo.Check.Refactor.CaseTrivialMatches, false},
{Credo.Check.Refactor.CondStatements, false},
{Credo.Check.Refactor.FilterCount, false},
{Credo.Check.Refactor.MapInto, false},
{Credo.Check.Refactor.MapJoin, false},
{Credo.Check.Refactor.NegatedConditionsInUnless, false},
{Credo.Check.Refactor.NegatedConditionsWithElse, false},
{Credo.Check.Refactor.PipeChainStart, false},
{Credo.Check.Refactor.RedundantWithClauseResult, false},
{Credo.Check.Refactor.UnlessWithElse, false},
{Credo.Check.Refactor.WithClauses, false},
{Credo.Check.Readability.MaxLineLength, false}
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
import_deps: [:ecto, :phoenix],
plugins: [Phoenix.LiveView.HTMLFormatter],
plugins: [Phoenix.LiveView.HTMLFormatter, Styler],
inputs: ["*.{heex,ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{heex,ex,exs}"],
subdirectories: ["priv/*/migrations"]
]
104 changes: 52 additions & 52 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@
# General application configuration
import Config

# 12 hours in seconds
max_session_time = 12 * 60 * 60

# Addresses an issue with Oban
# https://github.com/oban-bg/oban/issues/493#issuecomment-1187001822
config :arrow, Arrow.Repo,
parameters: [
tcp_keepalives_idle: "60",
tcp_keepalives_interval: "5",
tcp_keepalives_count: "3"
],
socket_options: [keepalive: true]

config :arrow, ArrowWeb.AuthManager,
issuer: "arrow",
max_session_time: max_session_time,
# 30 minutes
idle_time: 30 * 60

# Configures the endpoint
config :arrow, ArrowWeb.Endpoint,
url: [host: "localhost"],
render_errors: [view: ArrowWeb.ErrorView, accepts: ~w(html json)],
pubsub_server: Arrow.PubSub,
live_view: [signing_salt: "35DDvOCJ"]

# Configures Oban, the job processing library
config :arrow, Oban,
engine: Oban.Engines.Basic,
queues: [default: 10, gtfs_import: 1],
repo: Arrow.Repo

config :arrow,
ecto_repos: [Arrow.Repo],
aws_rds_mod: ExAws.RDS,
Expand Down Expand Up @@ -44,28 +76,7 @@ config :arrow,
hastus_export_storage_request_fn: {ExAws, :request},
use_username_prefix?: false

# Addresses an issue with Oban
# https://github.com/oban-bg/oban/issues/493#issuecomment-1187001822
config :arrow, Arrow.Repo,
parameters: [
tcp_keepalives_idle: "60",
tcp_keepalives_interval: "5",
tcp_keepalives_count: "3"
],
socket_options: [keepalive: true]

# Configures the endpoint
config :arrow, ArrowWeb.Endpoint,
url: [host: "localhost"],
render_errors: [view: ArrowWeb.ErrorView, accepts: ~w(html json)],
pubsub_server: Arrow.PubSub,
live_view: [signing_salt: "35DDvOCJ"]

# Configures Oban, the job processing library
config :arrow, Oban,
engine: Oban.Engines.Basic,
queues: [default: 10, gtfs_import: 1],
repo: Arrow.Repo
config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase

config :esbuild,
version: "0.17.11",
Expand All @@ -91,6 +102,25 @@ config :esbuild,
}
]

config :ex_aws, json_codec: Jason

config :ja_serializer,
key_format: :underscored

# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]

config :mime, :types, %{
"application/vnd.api+json" => ["json-api"]
}

config :phoenix, :format_encoders, "json-api": Jason

# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason

# Configure tailwind (the version is required)
config :tailwind,
version: "3.4.0",
Expand All @@ -103,15 +133,6 @@ config :tailwind,
cd: Path.expand("../assets", __DIR__)
]

# 12 hours in seconds
max_session_time = 12 * 60 * 60

config :arrow, ArrowWeb.AuthManager,
issuer: "arrow",
max_session_time: max_session_time,
# 30 minutes
idle_time: 30 * 60

config :ueberauth, Ueberauth,
providers: [
keycloak:
Expand All @@ -124,27 +145,6 @@ config :ueberauth, Ueberauth,
authorization_params_passthrough: ~w"prompt login_hint"}
]

# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]

# Use Jason for JSON parsing in Phoenix
config :phoenix, :json_library, Jason

config :phoenix, :format_encoders, "json-api": Jason

config :mime, :types, %{
"application/vnd.api+json" => ["json-api"]
}

config :ex_aws, json_codec: Jason

config :ja_serializer,
key_format: :underscored

config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"
45 changes: 21 additions & 24 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,14 @@ config :arrow, Arrow.Repo,
show_sensitive_data_on_connection_error: true,
pool_size: 10

config :arrow, ArrowWeb.AuthManager, secret_key: "test key"

# For development, we disable any cache and enable
# debugging and code reloading.
#
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with webpack to recompile .js and .css sources.
config :arrow, ArrowWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
secret_key_base: "local_secret_key_base_at_least_64_bytes_________________________________",
watchers: [
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
node:
~w(assets/node_modules/.bin/tsc --project assets --noEmit --watch --preserveWatchOutput),
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]}
]

config :arrow, ArrowWeb.AuthManager, secret_key: "test key"

# ## SSL Support
#
Expand All @@ -53,6 +41,17 @@ config :arrow, ArrowWeb.AuthManager, secret_key: "test key"
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.
config :arrow, ArrowWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
check_origin: false,
secret_key_base: "local_secret_key_base_at_least_64_bytes_________________________________",
watchers: [
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
node: ~w(assets/node_modules/.bin/tsc --project assets --noEmit --watch --preserveWatchOutput),
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]}
]

# Watch static and templates for browser reloading.
config :arrow, ArrowWeb.Endpoint,
Expand All @@ -64,16 +63,9 @@ config :arrow, ArrowWeb.Endpoint,
]
]

config :ueberauth, Ueberauth,
providers: [
keycloak: {Arrow.Ueberauth.Strategy.Fake, [groups: ["admin"]]}
]

config :arrow, :redirect_http?, false

# Enable dev routes for dashboard and mailbox
config :arrow, dev_routes: true

# Set prefix env for s3 uploads
config :arrow,
shape_storage_enabled?: true,
Expand All @@ -87,16 +79,21 @@ config :arrow,
# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"

# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime

# Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive.
config :phoenix, :stacktrace_depth, 20

# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime

config :phoenix_live_view,
# Include HEEx debug annotations as HTML comments in rendered markup
debug_heex_annotations: true

config :ueberauth, Ueberauth,
providers: [
keycloak: {Arrow.Ueberauth.Strategy.Fake, [groups: ["admin"]]}
]

# Enable helpful, but potentially expensive runtime checks
# enable_expensive_runtime_checks: true
15 changes: 7 additions & 8 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,23 @@ import Config
# which you should run after static files are built and
# before starting your production server.

config :arrow, Arrow.Repo, ssl: true
config :arrow, ArrowWeb.AuthManager, secret_key: {System, :get_env, ["ARROW_AUTH_SECRET"]}

config :arrow,
run_migrations_at_startup?: true,
ex_aws_requester: {ExAws, :request}

config :arrow,
shape_storage_enabled?: true,
gtfs_archive_storage_enabled?: true,
hastus_export_storage_enabled?: true

config :arrow, ArrowWeb.AuthManager, secret_key: {System, :get_env, ["ARROW_AUTH_SECRET"]}

# Do not print debug messages in production
config :logger,
backends: [:console, Sentry.LoggerBackend],
level: :info

config :arrow,
run_migrations_at_startup?: true,
ex_aws_requester: {ExAws, :request}

config :arrow, Arrow.Repo, ssl: true

# ## SSL Support
#
# To get SSL working, you will need to add the `https` key
Expand Down
Loading