Add Styler
This commit is contained in:
parent
c5b01954d7
commit
df1b84d5f4
@ -1,6 +1,6 @@
|
||||
[
|
||||
import_deps: [:oban, :ecto, :ecto_sql, :phoenix],
|
||||
subdirectories: ["priv/*/migrations"],
|
||||
plugins: [Phoenix.LiveView.HTMLFormatter],
|
||||
plugins: [Phoenix.LiveView.HTMLFormatter, Styler],
|
||||
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"]
|
||||
]
|
||||
|
@ -7,46 +7,23 @@
|
||||
# General application configuration
|
||||
import Config
|
||||
|
||||
config :tradex, Oban,
|
||||
engine: Oban.Engines.Basic,
|
||||
notifier: Oban.Notifiers.Postgres,
|
||||
queues: [default: 10],
|
||||
repo: Tradex.Repo
|
||||
|
||||
config :tradex,
|
||||
ecto_repos: [Tradex.Repo],
|
||||
generators: [timestamp_type: :utc_datetime]
|
||||
|
||||
# Configures the endpoint
|
||||
config :tradex, TradexWeb.Endpoint,
|
||||
url: [host: "localhost"],
|
||||
adapter: Bandit.PhoenixAdapter,
|
||||
render_errors: [
|
||||
formats: [html: TradexWeb.ErrorHTML, json: TradexWeb.ErrorJSON],
|
||||
layout: false
|
||||
],
|
||||
pubsub_server: Tradex.PubSub,
|
||||
live_view: [signing_salt: "i4cu1T7m"]
|
||||
|
||||
# Configures the mailer
|
||||
#
|
||||
# By default it uses the "Local" adapter which stores the emails
|
||||
# locally. You can see the emails in your browser, at "/dev/mailbox".
|
||||
#
|
||||
# For production it's recommended to configure a different adapter
|
||||
# at the `config/runtime.exs`.
|
||||
config :tradex, Tradex.Mailer, adapter: Swoosh.Adapters.Local
|
||||
|
||||
# Configure esbuild (the version is required)
|
||||
config :esbuild,
|
||||
version: "0.17.11",
|
||||
tradex: [
|
||||
args:
|
||||
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
|
||||
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__)}
|
||||
]
|
||||
|
||||
# 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
|
||||
|
||||
# Configure tailwind (the version is required)
|
||||
config :tailwind,
|
||||
version: "3.4.3",
|
||||
@ -59,14 +36,36 @@ config :tailwind,
|
||||
cd: Path.expand("../assets", __DIR__)
|
||||
]
|
||||
|
||||
# Configures Elixir's Logger
|
||||
config :logger, :console,
|
||||
format: "$time $metadata[$level] $message\n",
|
||||
metadata: [:request_id]
|
||||
config :tradex, Oban,
|
||||
engine: Oban.Engines.Basic,
|
||||
notifier: Oban.Notifiers.Postgres,
|
||||
queues: [default: 10],
|
||||
repo: Tradex.Repo
|
||||
|
||||
# Use Jason for JSON parsing in Phoenix
|
||||
config :phoenix, :json_library, Jason
|
||||
# Configures the mailer
|
||||
#
|
||||
# By default it uses the "Local" adapter which stores the emails
|
||||
# locally. You can see the emails in your browser, at "/dev/mailbox".
|
||||
#
|
||||
# For production it's recommended to configure a different adapter
|
||||
# at the `config/runtime.exs`.
|
||||
config :tradex, Tradex.Mailer, adapter: Swoosh.Adapters.Local
|
||||
|
||||
# Configures the endpoint
|
||||
config :tradex, TradexWeb.Endpoint,
|
||||
url: [host: "localhost"],
|
||||
adapter: Bandit.PhoenixAdapter,
|
||||
render_errors: [
|
||||
formats: [html: TradexWeb.ErrorHTML, json: TradexWeb.ErrorJSON],
|
||||
layout: false
|
||||
],
|
||||
pubsub_server: Tradex.PubSub,
|
||||
live_view: [signing_salt: "i4cu1T7m"]
|
||||
|
||||
config :tradex,
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
ecto_repos: [Tradex.Repo],
|
||||
generators: [timestamp_type: :utc_datetime]
|
||||
|
||||
# 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"
|
||||
|
@ -1,24 +1,59 @@
|
||||
import Config
|
||||
|
||||
# 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
|
||||
|
||||
config :phoenix_live_view,
|
||||
# Include HEEx debug annotations as HTML comments in rendered markup
|
||||
debug_heex_annotations: true,
|
||||
# Enable helpful, but potentially expensive runtime checks
|
||||
enable_expensive_runtime_checks: true
|
||||
|
||||
# Disable swoosh api client as it is only required for production adapters.
|
||||
config :swoosh, :api_client, false
|
||||
|
||||
# Configure your database
|
||||
config :tradex, Tradex.Repo,
|
||||
# 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 can use it
|
||||
# ## SSL Support
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
hostname: "localhost",
|
||||
database: "tradex_dev",
|
||||
stacktrace: true,
|
||||
# to bundle .js and .css sources.
|
||||
#
|
||||
# In order to use HTTPS in development, a self-signed
|
||||
show_sensitive_data_on_connection_error: true,
|
||||
pool_size: 10
|
||||
|
||||
# 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 can use it
|
||||
# to bundle .js and .css sources.
|
||||
config :tradex, TradexWeb.Endpoint,
|
||||
# Binding to loopback ipv4 address prevents access from other machines.
|
||||
# certificate can be generated by running the following
|
||||
|
||||
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
|
||||
# Mix task:
|
||||
#
|
||||
# mix phx.gen.cert
|
||||
#
|
||||
# Run `mix help phx.gen.cert` for more information.
|
||||
#
|
||||
# The `http:` config above can be replaced with:
|
||||
#
|
||||
# https: [
|
||||
# port: 4001,
|
||||
# cipher_suite: :strong,
|
||||
http: [ip: {127, 0, 0, 1}, port: 4000],
|
||||
check_origin: false,
|
||||
code_reloader: true,
|
||||
@ -29,21 +64,7 @@ config :tradex, TradexWeb.Endpoint,
|
||||
tailwind: {Tailwind, :install_and_run, [:tradex, ~w(--watch)]}
|
||||
]
|
||||
|
||||
# ## SSL Support
|
||||
#
|
||||
# In order to use HTTPS in development, a self-signed
|
||||
# certificate can be generated by running the following
|
||||
# Mix task:
|
||||
#
|
||||
# mix phx.gen.cert
|
||||
#
|
||||
# Run `mix help phx.gen.cert` for more information.
|
||||
#
|
||||
# The `http:` config above can be replaced with:
|
||||
#
|
||||
# https: [
|
||||
# port: 4001,
|
||||
# cipher_suite: :strong,
|
||||
# Watch static and templates for browser reloading.
|
||||
# keyfile: "priv/cert/selfsigned_key.pem",
|
||||
# certfile: "priv/cert/selfsigned.pem"
|
||||
# ],
|
||||
@ -52,7 +73,6 @@ config :tradex, TradexWeb.Endpoint,
|
||||
# configured to run both http and https servers on
|
||||
# different ports.
|
||||
|
||||
# Watch static and templates for browser reloading.
|
||||
config :tradex, TradexWeb.Endpoint,
|
||||
live_reload: [
|
||||
patterns: [
|
||||
@ -64,22 +84,3 @@ config :tradex, TradexWeb.Endpoint,
|
||||
|
||||
# Enable dev routes for dashboard and mailbox
|
||||
config :tradex, dev_routes: true
|
||||
|
||||
# Do not include metadata nor timestamps in development logs
|
||||
config :logger, :console, format: "[$level] $message\n"
|
||||
|
||||
# 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,
|
||||
# Enable helpful, but potentially expensive runtime checks
|
||||
enable_expensive_runtime_checks: true
|
||||
|
||||
# Disable swoosh api client as it is only required for production adapters.
|
||||
config :swoosh, :api_client, false
|
||||
|
@ -1,20 +1,21 @@
|
||||
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 :tradex, TradexWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
|
||||
|
||||
# Configures Swoosh API Client
|
||||
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Tradex.Finch
|
||||
|
||||
# Disable Swoosh Local Memory Storage
|
||||
config :swoosh, local: false
|
||||
|
||||
# Do not print debug messages in production
|
||||
config :logger, level: :info
|
||||
|
||||
# Configures Swoosh API Client
|
||||
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Tradex.Finch
|
||||
|
||||
# Note we also include the path to a cache manifest
|
||||
# containing the digested version of static files. This
|
||||
|
||||
# Disable Swoosh Local Memory Storage
|
||||
# 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 :swoosh, local: false
|
||||
|
||||
config :tradex, TradexWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
|
||||
|
||||
# Runtime production configuration, including reading
|
||||
# of environment variables, is done on config/runtime.exs.
|
||||
|
@ -30,12 +30,6 @@ if config_env() == :prod do
|
||||
|
||||
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
|
||||
|
||||
config :tradex, Tradex.Repo,
|
||||
# ssl: true,
|
||||
url: database_url,
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
||||
socket_options: maybe_ipv6
|
||||
|
||||
# The secret key base is used to sign/encrypt cookies and other secrets.
|
||||
# A default value is used in config/dev.exs and config/test.exs but you
|
||||
# want to use a different value for prod and you most likely don't want
|
||||
@ -51,7 +45,11 @@ if config_env() == :prod do
|
||||
host = System.get_env("PHX_HOST") || "example.com"
|
||||
port = String.to_integer(System.get_env("PORT") || "4000")
|
||||
|
||||
config :tradex, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
||||
config :tradex, Tradex.Repo,
|
||||
# ssl: true,
|
||||
url: database_url,
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
||||
socket_options: maybe_ipv6
|
||||
|
||||
config :tradex, TradexWeb.Endpoint,
|
||||
url: [host: host, port: 443, scheme: "https"],
|
||||
@ -65,6 +63,8 @@ if config_env() == :prod do
|
||||
],
|
||||
secret_key_base: secret_key_base
|
||||
|
||||
config :tradex, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
||||
|
||||
# ## SSL Support
|
||||
#
|
||||
# To get SSL working, you will need to add the `https` key
|
||||
|
@ -1,35 +1,8 @@
|
||||
import Config
|
||||
config :tradex, Oban, testing: :manual
|
||||
|
||||
# Only in tests, remove the complexity from the password hashing algorithm
|
||||
config :bcrypt_elixir, :log_rounds, 1
|
||||
|
||||
# Configure your database
|
||||
#
|
||||
# The MIX_TEST_PARTITION environment variable can be used
|
||||
# to provide built-in test partitioning in CI environment.
|
||||
# Run `mix help test` for more information.
|
||||
config :tradex, Tradex.Repo,
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
hostname: "localhost",
|
||||
database: "tradex_test#{System.get_env("MIX_TEST_PARTITION")}",
|
||||
pool: Ecto.Adapters.SQL.Sandbox,
|
||||
pool_size: System.schedulers_online() * 2
|
||||
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
config :tradex, TradexWeb.Endpoint,
|
||||
http: [ip: {127, 0, 0, 1}, port: 4002],
|
||||
secret_key_base: "pP8HLCaUfsAaCuJWdmHExGTUqj83ZvuIvjiWhCcXZx/FeGvxTukgbhirVEby/WHn",
|
||||
server: false
|
||||
|
||||
# In test we don't send emails
|
||||
config :tradex, Tradex.Mailer, adapter: Swoosh.Adapters.Test
|
||||
|
||||
# Disable swoosh api client as it is only required for production adapters
|
||||
config :swoosh, :api_client, false
|
||||
|
||||
# Print only warnings and errors during test
|
||||
config :logger, level: :warning
|
||||
|
||||
@ -39,3 +12,31 @@ config :phoenix, :plug_init_mode, :runtime
|
||||
# Enable helpful, but potentially expensive runtime checks
|
||||
config :phoenix_live_view,
|
||||
enable_expensive_runtime_checks: true
|
||||
|
||||
# Disable swoosh api client as it is only required for production adapters
|
||||
config :swoosh, :api_client, false
|
||||
|
||||
# Configure your database
|
||||
#
|
||||
# The MIX_TEST_PARTITION environment variable can be used
|
||||
config :tradex, Oban, testing: :manual
|
||||
|
||||
# In test we don't send emails
|
||||
# to provide built-in test partitioning in CI environment.
|
||||
# Run `mix help test` for more information.
|
||||
config :tradex, Tradex.Mailer, adapter: Swoosh.Adapters.Test
|
||||
|
||||
config :tradex, Tradex.Repo,
|
||||
username: "postgres",
|
||||
password: "postgres",
|
||||
hostname: "localhost",
|
||||
database: "tradex_test#{System.get_env("MIX_TEST_PARTITION")}",
|
||||
pool: Ecto.Adapters.SQL.Sandbox,
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
pool_size: System.schedulers_online() * 2
|
||||
|
||||
config :tradex, TradexWeb.Endpoint,
|
||||
http: [ip: {127, 0, 0, 1}, port: 4002],
|
||||
secret_key_base: "pP8HLCaUfsAaCuJWdmHExGTUqj83ZvuIvjiWhCcXZx/FeGvxTukgbhirVEby/WHn",
|
||||
server: false
|
||||
|
@ -4,9 +4,11 @@ defmodule Tradex.Accounts do
|
||||
"""
|
||||
|
||||
import Ecto.Query, warn: false
|
||||
alias Tradex.Repo
|
||||
|
||||
alias Tradex.Accounts.{User, UserToken, UserNotifier}
|
||||
alias Tradex.Accounts.User
|
||||
alias Tradex.Accounts.UserNotifier
|
||||
alias Tradex.Accounts.UserToken
|
||||
alias Tradex.Repo
|
||||
|
||||
## Database getters
|
||||
|
||||
@ -38,8 +40,7 @@ defmodule Tradex.Accounts do
|
||||
nil
|
||||
|
||||
"""
|
||||
def get_user_by_email_and_password(email, password)
|
||||
when is_binary(email) and is_binary(password) do
|
||||
def get_user_by_email_and_password(email, password) when is_binary(email) and is_binary(password) do
|
||||
user = Repo.get_by(User, email: email)
|
||||
if User.valid_password?(user, password), do: user
|
||||
end
|
||||
|
@ -1,5 +1,7 @@
|
||||
defmodule Tradex.Accounts.User do
|
||||
@moduledoc false
|
||||
use Tradex.Schema
|
||||
|
||||
import Ecto.Changeset
|
||||
|
||||
schema "users" do
|
||||
@ -126,7 +128,7 @@ defmodule Tradex.Accounts.User do
|
||||
Confirms the account by setting `confirmed_at`.
|
||||
"""
|
||||
def confirm_changeset(user) do
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
now = DateTime.truncate(DateTime.utc_now(), :second)
|
||||
change(user, confirmed_at: now)
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
defmodule Tradex.Accounts.UserNotifier do
|
||||
@moduledoc false
|
||||
import Swoosh.Email
|
||||
|
||||
alias Tradex.Mailer
|
||||
|
@ -1,6 +1,9 @@
|
||||
defmodule Tradex.Accounts.UserToken do
|
||||
@moduledoc false
|
||||
use Tradex.Schema
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
alias Tradex.Accounts.UserToken
|
||||
|
||||
@hash_algorithm :sha256
|
||||
|
@ -1,3 +1,4 @@
|
||||
defmodule Tradex.Mailer do
|
||||
@moduledoc false
|
||||
use Swoosh.Mailer, otp_app: :tradex
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
defmodule Tradex.Schema do
|
||||
@moduledoc false
|
||||
defmacro __using__(opts) do
|
||||
quote do
|
||||
use Ecto.Schema
|
||||
|
@ -23,10 +23,11 @@ defmodule TradexWeb do
|
||||
quote do
|
||||
use Phoenix.Router, helpers: false
|
||||
|
||||
# Import common connection and controller functions to use in pipelines
|
||||
import Plug.Conn
|
||||
import Phoenix.Controller
|
||||
import Phoenix.LiveView.Router
|
||||
|
||||
# Import common connection and controller functions to use in pipelines
|
||||
import Plug.Conn
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -17,6 +17,7 @@ defmodule TradexWeb.CoreComponents do
|
||||
use Phoenix.Component
|
||||
use Gettext, backend: TradexWeb.Gettext
|
||||
|
||||
alias Phoenix.HTML.FormField
|
||||
alias Phoenix.LiveView.JS
|
||||
|
||||
@doc """
|
||||
@ -278,8 +279,7 @@ defmodule TradexWeb.CoreComponents do
|
||||
values: ~w(checkbox color date datetime-local email file month number password
|
||||
range search select tel text textarea time url week)
|
||||
|
||||
attr :field, Phoenix.HTML.FormField,
|
||||
doc: "a form field struct retrieved from the form, for example: @form[:email]"
|
||||
attr :field, FormField, doc: "a form field struct retrieved from the form, for example: @form[:email]"
|
||||
|
||||
attr :errors, :list, default: []
|
||||
attr :checked, :boolean, doc: "the checked flag for checkbox inputs"
|
||||
@ -287,11 +287,10 @@ defmodule TradexWeb.CoreComponents do
|
||||
attr :options, :list, doc: "the options to pass to Phoenix.HTML.Form.options_for_select/2"
|
||||
attr :multiple, :boolean, default: false, doc: "the multiple flag for select inputs"
|
||||
|
||||
attr :rest, :global,
|
||||
include: ~w(accept autocomplete capture cols disabled form list max maxlength min minlength
|
||||
attr :rest, :global, include: ~w(accept autocomplete capture cols disabled form list max maxlength min minlength
|
||||
multiple pattern placeholder readonly required rows size step)
|
||||
|
||||
def input(%{field: %Phoenix.HTML.FormField{} = field} = assigns) do
|
||||
def input(%{field: %FormField{} = field} = assigns) do
|
||||
errors = if Phoenix.Component.used_input?(field), do: field.errors, else: []
|
||||
|
||||
assigns
|
||||
@ -604,8 +603,7 @@ defmodule TradexWeb.CoreComponents do
|
||||
to: selector,
|
||||
time: 300,
|
||||
transition:
|
||||
{"transition-all transform ease-out duration-300",
|
||||
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
||||
{"transition-all transform ease-out duration-300", "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
||||
"opacity-100 translate-y-0 sm:scale-100"}
|
||||
)
|
||||
end
|
||||
@ -615,8 +613,7 @@ defmodule TradexWeb.CoreComponents do
|
||||
to: selector,
|
||||
time: 200,
|
||||
transition:
|
||||
{"transition-all transform ease-in duration-200",
|
||||
"opacity-100 translate-y-0 sm:scale-100",
|
||||
{"transition-all transform ease-in duration-200", "opacity-100 translate-y-0 sm:scale-100",
|
||||
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"}
|
||||
)
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserConfirmationInstructionsLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserConfirmationLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserForgotPasswordLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserLoginLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
def render(assigns) do
|
||||
|
@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserRegistrationLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserResetPasswordLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@ -1,4 +1,5 @@
|
||||
defmodule TradexWeb.UserSettingsLive do
|
||||
@moduledoc false
|
||||
use TradexWeb, :live_view
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
@ -1,5 +1,7 @@
|
||||
defmodule TradexWeb.Telemetry do
|
||||
@moduledoc false
|
||||
use Supervisor
|
||||
|
||||
import Telemetry.Metrics
|
||||
|
||||
def start_link(arg) do
|
||||
@ -70,8 +72,7 @@ defmodule TradexWeb.Telemetry do
|
||||
),
|
||||
summary("tradex.repo.query.idle_time",
|
||||
unit: {:native, :millisecond},
|
||||
description:
|
||||
"The time the connection spent waiting before being checked out for the query"
|
||||
description: "The time the connection spent waiting before being checked out for the query"
|
||||
),
|
||||
|
||||
# VM Metrics
|
||||
|
@ -1,8 +1,9 @@
|
||||
defmodule TradexWeb.UserAuth do
|
||||
@moduledoc false
|
||||
use TradexWeb, :verified_routes
|
||||
|
||||
import Plug.Conn
|
||||
import Phoenix.Controller
|
||||
import Plug.Conn
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
||||
|
10
mix.exs
10
mix.exs
@ -45,12 +45,7 @@ defmodule Tradex.MixProject do
|
||||
{:esbuild, "~> 0.8", runtime: Mix.env() == :dev},
|
||||
{:tailwind, "~> 0.2", runtime: Mix.env() == :dev},
|
||||
{:heroicons,
|
||||
github: "tailwindlabs/heroicons",
|
||||
tag: "v2.1.1",
|
||||
sparse: "optimized",
|
||||
app: false,
|
||||
compile: false,
|
||||
depth: 1},
|
||||
github: "tailwindlabs/heroicons", tag: "v2.1.1", sparse: "optimized", app: false, compile: false, depth: 1},
|
||||
{:swoosh, "~> 1.5"},
|
||||
{:finch, "~> 0.13"},
|
||||
{:telemetry_metrics, "~> 1.0"},
|
||||
@ -61,7 +56,8 @@ defmodule Tradex.MixProject do
|
||||
{:bandit, "~> 1.5"},
|
||||
{:uuidv7, "~> 1.0"},
|
||||
{:igniter, "~> 0.5"},
|
||||
{:oban, "~> 2.19"}
|
||||
{:oban, "~> 2.19"},
|
||||
{:styler, "~> 1.2", only: [:dev, :test], runtime: false}
|
||||
]
|
||||
end
|
||||
|
||||
|
1
mix.lock
1
mix.lock
@ -42,6 +42,7 @@
|
||||
"rewrite": {:hex, :rewrite, "1.1.2", "f5a5d10f5fed1491a6ff48e078d4585882695962ccc9e6c779bae025d1f92eda", [:mix], [{:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}, {:text_diff, "~> 0.1", [hex: :text_diff, repo: "hexpm", optional: false]}], "hexpm", "7f8b94b1e3528d0a47b3e8b7bfeca559d2948a65fa7418a9ad7d7712703d39d4"},
|
||||
"sourceror": {:hex, :sourceror, "1.7.1", "599d78f4cc2be7d55c9c4fd0a8d772fd0478e3a50e726697c20d13d02aa056d4", [:mix], [], "hexpm", "cd6f268fe29fa00afbc535e215158680a0662b357dc784646d7dff28ac65a0fc"},
|
||||
"spitfire": {:hex, :spitfire, "0.1.4", "8fe0df66e735323e4f2a56e719603391b160dd68efd922cadfbb85a2cf6c68af", [:mix], [], "hexpm", "d40d850f4ede5235084876246756b90c7bcd12994111d57c55e2e1e23ac3fe61"},
|
||||
"styler": {:hex, :styler, "1.3.3", "5196fc9e9bf1254af4337b051103d38532c2f500b0f01bc6f53f56ee678f65e6", [:mix], [], "hexpm", "c275f73f2ff1b7dfafb03a0f8cf3e928709a235a2b049162b40168f53ba3a07c"},
|
||||
"swoosh": {:hex, :swoosh, "1.17.6", "27ff070f96246e35b7105ab1c52b2b689f523a3cb83ed9faadb2f33bd653ccba", [:mix], [{:bandit, ">= 1.0.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:cowboy, "~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:ex_aws, "~> 2.1", [hex: :ex_aws, repo: "hexpm", optional: true]}, {:finch, "~> 0.6", [hex: :finch, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13 or ~> 1.0", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mua, "~> 0.2.3", [hex: :mua, repo: "hexpm", optional: true]}, {:multipart, "~> 0.4", [hex: :multipart, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:req, "~> 0.5 or ~> 1.0", [hex: :req, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9798f3e72165f40c950f6762c06dab68afcdcf616138fc4a07965c09c250e1e2"},
|
||||
"tailwind": {:hex, :tailwind, "0.2.4", "5706ec47182d4e7045901302bf3a333e80f3d1af65c442ba9a9eed152fb26c2e", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "c6e4a82b8727bab593700c998a4d98cf3d8025678bfde059aed71d0000c3e463"},
|
||||
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
|
||||
|
@ -19,15 +19,14 @@ defmodule TradexWeb.ConnCase do
|
||||
|
||||
using do
|
||||
quote do
|
||||
use TradexWeb, :verified_routes
|
||||
import Phoenix.ConnTest
|
||||
import Plug.Conn
|
||||
import TradexWeb.ConnCase
|
||||
# The default endpoint for testing
|
||||
@endpoint TradexWeb.Endpoint
|
||||
|
||||
use TradexWeb, :verified_routes
|
||||
|
||||
# Import conveniences for testing with connections
|
||||
import Plug.Conn
|
||||
import Phoenix.ConnTest
|
||||
import TradexWeb.ConnCase
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -16,14 +16,16 @@ defmodule Tradex.DataCase do
|
||||
|
||||
use ExUnit.CaseTemplate
|
||||
|
||||
alias Ecto.Adapters.SQL.Sandbox
|
||||
|
||||
using do
|
||||
quote do
|
||||
alias Tradex.Repo
|
||||
|
||||
import Ecto
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
import Tradex.DataCase
|
||||
|
||||
alias Tradex.Repo
|
||||
end
|
||||
end
|
||||
|
||||
@ -36,8 +38,8 @@ defmodule Tradex.DataCase do
|
||||
Sets up the sandbox based on the test tags.
|
||||
"""
|
||||
def setup_sandbox(tags) do
|
||||
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Tradex.Repo, shared: not tags[:async])
|
||||
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
|
||||
pid = Sandbox.start_owner!(Tradex.Repo, shared: not tags[:async])
|
||||
on_exit(fn -> Sandbox.stop_owner(pid) end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
@ -1,10 +1,11 @@
|
||||
defmodule Tradex.AccountsTest do
|
||||
use Tradex.DataCase
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
||||
import Tradex.AccountsFixtures
|
||||
alias Tradex.Accounts.{User, UserToken}
|
||||
|
||||
alias Tradex.Accounts
|
||||
alias Tradex.Accounts.User
|
||||
alias Tradex.Accounts.UserToken
|
||||
|
||||
describe "get_user_by_email/1" do
|
||||
test "does not return the user if the email does not exist" do
|
||||
|
@ -56,13 +56,9 @@ defmodule TradexWeb.UserSessionControllerTest do
|
||||
|
||||
test "login following registration", %{conn: conn, user: user} do
|
||||
conn =
|
||||
conn
|
||||
|> post(~p"/users/log_in", %{
|
||||
post(conn, ~p"/users/log_in", %{
|
||||
"_action" => "registered",
|
||||
"user" => %{
|
||||
"email" => user.email,
|
||||
"password" => valid_user_password()
|
||||
}
|
||||
"user" => %{"email" => user.email, "password" => valid_user_password()}
|
||||
})
|
||||
|
||||
assert redirected_to(conn) == ~p"/"
|
||||
@ -71,13 +67,9 @@ defmodule TradexWeb.UserSessionControllerTest do
|
||||
|
||||
test "login following password update", %{conn: conn, user: user} do
|
||||
conn =
|
||||
conn
|
||||
|> post(~p"/users/log_in", %{
|
||||
post(conn, ~p"/users/log_in", %{
|
||||
"_action" => "password_updated",
|
||||
"user" => %{
|
||||
"email" => user.email,
|
||||
"password" => valid_user_password()
|
||||
}
|
||||
"user" => %{"email" => user.email, "password" => valid_user_password()}
|
||||
})
|
||||
|
||||
assert redirected_to(conn) == ~p"/users/settings"
|
||||
|
@ -55,9 +55,7 @@ defmodule TradexWeb.UserConfirmationLiveTest do
|
||||
"User confirmation link is invalid or it has expired"
|
||||
|
||||
# when logged in
|
||||
conn =
|
||||
build_conn()
|
||||
|> log_in_user(user)
|
||||
conn = log_in_user(build_conn(), user)
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/users/confirm/#{token}")
|
||||
|
||||
|
@ -45,9 +45,7 @@ defmodule TradexWeb.UserLoginLiveTest do
|
||||
{:ok, lv, _html} = live(conn, ~p"/users/log_in")
|
||||
|
||||
form =
|
||||
form(lv, "#login_form",
|
||||
user: %{email: "test@email.com", password: "123456", remember_me: true}
|
||||
)
|
||||
form(lv, "#login_form", user: %{email: "test@email.com", password: "123456", remember_me: true})
|
||||
|
||||
conn = submit_form(form, conn)
|
||||
|
||||
|
@ -39,9 +39,7 @@ defmodule TradexWeb.UserResetPasswordLiveTest do
|
||||
result =
|
||||
lv
|
||||
|> element("#reset_password_form")
|
||||
|> render_change(
|
||||
user: %{"password" => "secret12", "password_confirmation" => "secret123456"}
|
||||
)
|
||||
|> render_change(user: %{"password" => "secret12", "password_confirmation" => "secret123456"})
|
||||
|
||||
assert result =~ "should be at least 12 character"
|
||||
assert result =~ "does not match password"
|
||||
|
@ -1,10 +1,11 @@
|
||||
defmodule TradexWeb.UserSettingsLiveTest do
|
||||
use TradexWeb.ConnCase, async: true
|
||||
|
||||
alias Tradex.Accounts
|
||||
import Phoenix.LiveViewTest
|
||||
import Tradex.AccountsFixtures
|
||||
|
||||
alias Tradex.Accounts
|
||||
|
||||
describe "Settings page" do
|
||||
test "renders settings page", %{conn: conn} do
|
||||
{:ok, _lv, html} =
|
||||
|
@ -1,10 +1,11 @@
|
||||
defmodule TradexWeb.UserAuthTest do
|
||||
use TradexWeb.ConnCase, async: true
|
||||
|
||||
import Tradex.AccountsFixtures
|
||||
|
||||
alias Phoenix.LiveView
|
||||
alias Tradex.Accounts
|
||||
alias TradexWeb.UserAuth
|
||||
import Tradex.AccountsFixtures
|
||||
|
||||
@remember_me_cookie "_tradex_web_user_remember_me"
|
||||
|
||||
@ -139,7 +140,7 @@ defmodule TradexWeb.UserAuthTest do
|
||||
end
|
||||
|
||||
test "assigns nil to current_user assign if there isn't a user_token", %{conn: conn} do
|
||||
session = conn |> get_session()
|
||||
session = get_session(conn)
|
||||
|
||||
{:cont, updated_socket} =
|
||||
UserAuth.on_mount(:mount_current_user, %{}, session, %LiveView.Socket{})
|
||||
@ -173,7 +174,7 @@ defmodule TradexWeb.UserAuthTest do
|
||||
end
|
||||
|
||||
test "redirects to login page if there isn't a user_token", %{conn: conn} do
|
||||
session = conn |> get_session()
|
||||
session = get_session(conn)
|
||||
|
||||
socket = %LiveView.Socket{
|
||||
endpoint: TradexWeb.Endpoint,
|
||||
@ -200,7 +201,7 @@ defmodule TradexWeb.UserAuthTest do
|
||||
end
|
||||
|
||||
test "doesn't redirect if there is no authenticated user", %{conn: conn} do
|
||||
session = conn |> get_session()
|
||||
session = get_session(conn)
|
||||
|
||||
assert {:cont, _updated_socket} =
|
||||
UserAuth.on_mount(
|
||||
|
Loading…
x
Reference in New Issue
Block a user