initial: first commit ever

This commit is contained in:
2024-10-07 23:20:11 +00:00
commit ec3b82cd00
65 changed files with 2797 additions and 0 deletions

45
config/config.exs Normal file
View File

@@ -0,0 +1,45 @@
import Config
config :slax,
ecto_repos: [Slax.Repo],
generators: [timestamp_type: :utc_datetime]
config :slax, SlaxWeb.Endpoint,
url: [host: "localhost"],
adapter: Bandit.PhoenixAdapter,
render_errors: [
formats: [html: SlaxWeb.ErrorHTML, json: SlaxWeb.ErrorJSON],
layout: false
],
pubsub_server: Slax.PubSub,
live_view: [signing_salt: "NVy/Rvtl"]
config :slax, Slax.Mailer, adapter: Swoosh.Adapters.Local
config :esbuild,
version: "0.17.11",
slax: [
args:
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]
config :tailwind,
version: "3.4.3",
slax: [
args: ~w(
--config=tailwind.config.js
--input=css/app.css
--output=../priv/static/assets/app.css
),
cd: Path.expand("../assets", __DIR__)
]
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
config :phoenix, :json_library, Jason
import_config "#{config_env()}.exs"

48
config/dev.exs Normal file
View File

@@ -0,0 +1,48 @@
import Config
config :slax, Slax.Repo,
username: System.get_env("PGUSER", "postgres"),
password: System.get_env("PGPASSWORD", "postgres"),
hostname: System.get_env("PGHOST", "localhost"),
database: System.get_env("PGDATABASE", "slax_dev"),
stacktrace: true,
show_sensitive_data_on_connection_error: true,
pool_size: 10
config :slax, SlaxWeb.Endpoint,
http: [ip: {0, 0, 0, 0}, port: 4000],
check_origin: false,
code_reloader: true,
debug_errors: true,
secret_key_base: "E3KGuV1FenlF8ZEsLrS07FT2dauJGgGzsetqSfhG2u26Z4Bt0SQqaqpNsgyjhnSo",
watchers: [
esbuild: {Esbuild, :install_and_run, [:slax, ~w(--sourcemap=inline --watch)]},
tailwind: {Tailwind, :install_and_run, [:slax, ~w(--watch)]}
]
config :slax, SlaxWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/slax_web/(controllers|live|components)/.*(ex|heex)$"
]
]
config :slax, dev_routes: true
config :testcontainers,
database_enabled: System.get_env("TESTCONTAINER_DATABASE_ENABLED") in ~w(true 1),
database_volume: "slax_database"
config :logger, :console, format: "[$level] $message\n"
config :phoenix, :stacktrace_depth, 20
config :phoenix, :plug_init_mode, :runtime
config :phoenix_live_view,
debug_heex_annotations: true,
enable_expensive_runtime_checks: true
config :swoosh, :api_client, false

20
config/prod.exs Normal file
View File

@@ -0,0 +1,20 @@
import Config
# Note we also include the path to a cache manifest
# containing the digested version of static files. This
# manifest is generated by the `mix assets.deploy` task,
# which you should run after static files are built and
# before starting your production server.
config :slax, SlaxWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
# Configures Swoosh API Client
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Slax.Finch
# Disable Swoosh Local Memory Storage
config :swoosh, local: false
# Do not print debug messages in production
config :logger, level: :info
# Runtime production configuration, including reading
# of environment variables, is done on config/runtime.exs.

76
config/runtime.exs Normal file
View File

@@ -0,0 +1,76 @@
import Config
# config/runtime.exs is executed for all environments, including
# during releases. It is executed after compilation and before the
# system starts, so it is typically used to load production configuration
# and secrets from environment variables or elsewhere. Do not define
# any compile-time configuration in here, as it won't be applied.
# The block below contains prod specific runtime configuration.
# ## Using releases
#
# If you use `mix release`, you need to explicitly enable the server
# by passing the PHX_SERVER=true when you start it:
#
# PHX_SERVER=true bin/slax start
#
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
# script that automatically sets the env var above.
if System.get_env("PHX_SERVER") do
config :slax, SlaxWeb.Endpoint, server: true
end
if config_env() == :prod do
database_url =
System.get_env("DATABASE_URL") ||
raise """
environment variable DATABASE_URL is missing.
For example: ecto://USER:PASS@HOST/DATABASE
"""
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
config :slax, Slax.Repo,
# ssl: true,
url: database_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
socket_options: maybe_ipv6
host = System.get_env("PHX_HOST") || "example.com"
port = String.to_integer(System.get_env("PORT") || "4000")
secret_key_base =
System.get_env("SECRET_KEY_BASE") ||
raise """
environment variable SECRET_KEY_BASE is missing.
You can generate one by calling: mix phx.gen.secret
"""
config :slax, SlaxWeb.Endpoint,
url: [host: host, port: 443, scheme: "https"],
http: [
ip: {0, 0, 0, 0, 0, 0, 0, 0},
port: port
],
secret_key_base: secret_key_base
config :slax, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
# ## Configuring the mailer
#
# In production you need to configure the mailer to use a different adapter.
# Also, you may need to configure the Swoosh API client of your choice if you
# are not using SMTP. Here is an example of the configuration:
#
# config :slax, Slax.Mailer,
# adapter: Swoosh.Adapters.Mailgun,
# api_key: System.get_env("MAILGUN_API_KEY"),
# domain: System.get_env("MAILGUN_DOMAIN")
#
# For this example you need include a HTTP client required by Swoosh API client.
# Swoosh supports Hackney and Finch out of the box:
#
# config :swoosh, :api_client, Swoosh.ApiClient.Hackney
#
# See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
end

29
config/test.exs Normal file
View File

@@ -0,0 +1,29 @@
import Config
config :slax, Slax.Repo,
username: System.get_env("PGUSER", "postgres"),
password: System.get_env("PGPASSWORD", "postgres"),
hostname: System.get_env("PGHOST", "localhost"),
# database: "#{System.get_env("PGDATABASE", "slax_test")}#{System.get_env("MIX_TEST_PARTITION")}",
database: System.get_env("PGDATABASE", "slax_test"),
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: System.schedulers_online() * 2
config :slax, SlaxWeb.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 4002],
secret_key_base: "JqUjCORrhK47ZnO5iziflaHRCLscDeOWm28tC01c9vrPvcrzRO12ZOgbahtc4sgw",
server: false
config :slax, Slax.Mailer, adapter: Swoosh.Adapters.Test
config :testcontainers,
database_enabled: System.get_env("TESTCONTAINER_DATABASE_ENABLED") in ~w(true 1)
config :swoosh, :api_client, false
config :logger, level: :warning
config :phoenix, :plug_init_mode, :runtime
config :phoenix_live_view,
enable_expensive_runtime_checks: true