init SlideLife
This commit is contained in:
26
.gitignore
vendored
26
.gitignore
vendored
@ -1,37 +1,15 @@
|
|||||||
# The directory Mix will write compiled artifacts to.
|
/.lexical/
|
||||||
/_build/
|
/_build/
|
||||||
|
|
||||||
# If you run "mix test --cover", coverage assets end up here.
|
|
||||||
/cover/
|
/cover/
|
||||||
|
|
||||||
# The directory Mix downloads your dependencies sources to.
|
|
||||||
/deps/
|
/deps/
|
||||||
|
|
||||||
# Where 3rd-party dependencies like ExDoc output generated docs.
|
|
||||||
/doc/
|
/doc/
|
||||||
|
|
||||||
# Ignore .fetch files in case you like to edit your project deps locally.
|
|
||||||
/.fetch
|
/.fetch
|
||||||
|
|
||||||
# If the VM crashes, it generates a dump, let's ignore it too.
|
|
||||||
erl_crash.dump
|
erl_crash.dump
|
||||||
|
|
||||||
# Also ignore archive artifacts (built via "mix archive.build").
|
|
||||||
*.ez
|
*.ez
|
||||||
|
|
||||||
# Temporary files, for example, from tests.
|
|
||||||
/tmp/
|
/tmp/
|
||||||
|
slide_life-*.tar
|
||||||
# Ignore package tarball (built via "mix hex.build").
|
|
||||||
modern_base-*.tar
|
|
||||||
|
|
||||||
# Ignore assets that are produced by build tools.
|
|
||||||
/priv/static/assets/
|
/priv/static/assets/
|
||||||
|
|
||||||
# Ignore digested assets cache.
|
|
||||||
/priv/static/cache_manifest.json
|
/priv/static/cache_manifest.json
|
||||||
|
|
||||||
# In case you use Node.js/npm, you want to ignore these.
|
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
/assets/node_modules/
|
/assets/node_modules/
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# ModernBase
|
# SlideLife
|
||||||
|
|
||||||
To start your Phoenix server:
|
To start your Phoenix server:
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ const path = require("path")
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
content: [
|
content: [
|
||||||
"./js/**/*.js",
|
"./js/**/*.js",
|
||||||
"../lib/modern_base_web.ex",
|
"../lib/slide_life_web.ex",
|
||||||
"../lib/modern_base_web/**/*.*ex"
|
"../lib/slide_life_web/**/*.*ex"
|
||||||
],
|
],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
|
@ -7,19 +7,19 @@
|
|||||||
# General application configuration
|
# General application configuration
|
||||||
import Config
|
import Config
|
||||||
|
|
||||||
config :modern_base,
|
config :slide_life,
|
||||||
ecto_repos: [ModernBase.Repo],
|
ecto_repos: [SlideLife.Repo],
|
||||||
generators: [timestamp_type: :utc_datetime]
|
generators: [timestamp_type: :utc_datetime]
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
config :modern_base, ModernBaseWeb.Endpoint,
|
config :slide_life, SlideLifeWeb.Endpoint,
|
||||||
url: [host: "localhost"],
|
url: [host: "localhost"],
|
||||||
adapter: Bandit.PhoenixAdapter,
|
adapter: Bandit.PhoenixAdapter,
|
||||||
render_errors: [
|
render_errors: [
|
||||||
formats: [html: ModernBaseWeb.ErrorHTML, json: ModernBaseWeb.ErrorJSON],
|
formats: [html: SlideLifeWeb.ErrorHTML, json: SlideLifeWeb.ErrorJSON],
|
||||||
layout: false
|
layout: false
|
||||||
],
|
],
|
||||||
pubsub_server: ModernBase.PubSub,
|
pubsub_server: SlideLife.PubSub,
|
||||||
live_view: [signing_salt: "UVlXhkXp"]
|
live_view: [signing_salt: "UVlXhkXp"]
|
||||||
|
|
||||||
# Configures the mailer
|
# Configures the mailer
|
||||||
@ -29,12 +29,12 @@ config :modern_base, ModernBaseWeb.Endpoint,
|
|||||||
#
|
#
|
||||||
# For production it's recommended to configure a different adapter
|
# For production it's recommended to configure a different adapter
|
||||||
# at the `config/runtime.exs`.
|
# at the `config/runtime.exs`.
|
||||||
config :modern_base, ModernBase.Mailer, adapter: Swoosh.Adapters.Local
|
config :slide_life, SlideLife.Mailer, adapter: Swoosh.Adapters.Local
|
||||||
|
|
||||||
# Configure esbuild (the version is required)
|
# Configure esbuild (the version is required)
|
||||||
config :esbuild,
|
config :esbuild,
|
||||||
version: "0.17.11",
|
version: "0.17.11",
|
||||||
modern_base: [
|
slide_life: [
|
||||||
args:
|
args:
|
||||||
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
|
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
|
||||||
cd: Path.expand("../assets", __DIR__),
|
cd: Path.expand("../assets", __DIR__),
|
||||||
@ -44,7 +44,7 @@ config :esbuild,
|
|||||||
# Configure tailwind (the version is required)
|
# Configure tailwind (the version is required)
|
||||||
config :tailwind,
|
config :tailwind,
|
||||||
version: "3.4.0",
|
version: "3.4.0",
|
||||||
modern_base: [
|
slide_life: [
|
||||||
args: ~w(
|
args: ~w(
|
||||||
--config=tailwind.config.js
|
--config=tailwind.config.js
|
||||||
--input=css/app.css
|
--input=css/app.css
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import Config
|
import Config
|
||||||
|
|
||||||
# Configure your database
|
# Configure your database
|
||||||
config :modern_base, ModernBase.Repo,
|
config :slide_life, SlideLife.Repo,
|
||||||
username: "postgres",
|
username: "postgres",
|
||||||
password: "postgres",
|
password: "postgres",
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
database: "modern_base_dev",
|
database: "slide_life_dev",
|
||||||
stacktrace: true,
|
stacktrace: true,
|
||||||
show_sensitive_data_on_connection_error: true,
|
show_sensitive_data_on_connection_error: true,
|
||||||
pool_size: 10
|
pool_size: 10
|
||||||
@ -16,7 +16,7 @@ config :modern_base, ModernBase.Repo,
|
|||||||
# The watchers configuration can be used to run external
|
# The watchers configuration can be used to run external
|
||||||
# watchers to your application. For example, we can use it
|
# watchers to your application. For example, we can use it
|
||||||
# to bundle .js and .css sources.
|
# to bundle .js and .css sources.
|
||||||
config :modern_base, ModernBaseWeb.Endpoint,
|
config :slide_life, SlideLifeWeb.Endpoint,
|
||||||
# Binding to loopback ipv4 address prevents access from other machines.
|
# Binding to loopback ipv4 address prevents access from other machines.
|
||||||
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
|
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
|
||||||
http: [ip: {127, 0, 0, 1}, port: 4000],
|
http: [ip: {127, 0, 0, 1}, port: 4000],
|
||||||
@ -25,8 +25,8 @@ config :modern_base, ModernBaseWeb.Endpoint,
|
|||||||
debug_errors: true,
|
debug_errors: true,
|
||||||
secret_key_base: "SJCi/gfKcoIeiOLcl5pcNoMsAtluCExbdb66zFwuSrMPjKHr/DumTB35OCXisztJ",
|
secret_key_base: "SJCi/gfKcoIeiOLcl5pcNoMsAtluCExbdb66zFwuSrMPjKHr/DumTB35OCXisztJ",
|
||||||
watchers: [
|
watchers: [
|
||||||
esbuild: {Esbuild, :install_and_run, [:modern_base, ~w(--sourcemap=inline --watch)]},
|
esbuild: {Esbuild, :install_and_run, [:slide_life, ~w(--sourcemap=inline --watch)]},
|
||||||
tailwind: {Tailwind, :install_and_run, [:modern_base, ~w(--watch)]}
|
tailwind: {Tailwind, :install_and_run, [:slide_life, ~w(--watch)]}
|
||||||
]
|
]
|
||||||
|
|
||||||
# ## SSL Support
|
# ## SSL Support
|
||||||
@ -53,17 +53,17 @@ config :modern_base, ModernBaseWeb.Endpoint,
|
|||||||
# different ports.
|
# different ports.
|
||||||
|
|
||||||
# Watch static and templates for browser reloading.
|
# Watch static and templates for browser reloading.
|
||||||
config :modern_base, ModernBaseWeb.Endpoint,
|
config :slide_life, SlideLifeWeb.Endpoint,
|
||||||
live_reload: [
|
live_reload: [
|
||||||
patterns: [
|
patterns: [
|
||||||
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",
|
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",
|
||||||
~r"priv/gettext/.*(po)$",
|
~r"priv/gettext/.*(po)$",
|
||||||
~r"lib/modern_base_web/(controllers|live|components)/.*(ex|heex)$"
|
~r"lib/slide_life_web/(controllers|live|components)/.*(ex|heex)$"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
# Enable dev routes for dashboard and mailbox
|
# Enable dev routes for dashboard and mailbox
|
||||||
config :modern_base, dev_routes: true
|
config :slide_life, dev_routes: true
|
||||||
|
|
||||||
# Do not include metadata nor timestamps in development logs
|
# Do not include metadata nor timestamps in development logs
|
||||||
config :logger, :console, format: "[$level] $message\n"
|
config :logger, :console, format: "[$level] $message\n"
|
||||||
|
@ -5,11 +5,11 @@ import Config
|
|||||||
# manifest is generated by the `mix assets.deploy` task,
|
# manifest is generated by the `mix assets.deploy` task,
|
||||||
# which you should run after static files are built and
|
# which you should run after static files are built and
|
||||||
# before starting your production server.
|
# before starting your production server.
|
||||||
config :modern_base, ModernBaseWeb.Endpoint,
|
config :slide_life, SlideLifeWeb.Endpoint,
|
||||||
cache_static_manifest: "priv/static/cache_manifest.json"
|
cache_static_manifest: "priv/static/cache_manifest.json"
|
||||||
|
|
||||||
# Configures Swoosh API Client
|
# Configures Swoosh API Client
|
||||||
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: ModernBase.Finch
|
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: SlideLife.Finch
|
||||||
|
|
||||||
# Disable Swoosh Local Memory Storage
|
# Disable Swoosh Local Memory Storage
|
||||||
config :swoosh, local: false
|
config :swoosh, local: false
|
||||||
|
@ -12,12 +12,12 @@ import Config
|
|||||||
# If you use `mix release`, you need to explicitly enable the server
|
# If you use `mix release`, you need to explicitly enable the server
|
||||||
# by passing the PHX_SERVER=true when you start it:
|
# by passing the PHX_SERVER=true when you start it:
|
||||||
#
|
#
|
||||||
# PHX_SERVER=true bin/modern_base start
|
# PHX_SERVER=true bin/slide_life start
|
||||||
#
|
#
|
||||||
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
|
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
|
||||||
# script that automatically sets the env var above.
|
# script that automatically sets the env var above.
|
||||||
if System.get_env("PHX_SERVER") do
|
if System.get_env("PHX_SERVER") do
|
||||||
config :modern_base, ModernBaseWeb.Endpoint, server: true
|
config :slide_life, SlideLifeWeb.Endpoint, server: true
|
||||||
end
|
end
|
||||||
|
|
||||||
if config_env() == :prod do
|
if config_env() == :prod do
|
||||||
@ -30,7 +30,7 @@ if config_env() == :prod do
|
|||||||
|
|
||||||
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
|
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
|
||||||
|
|
||||||
config :modern_base, ModernBase.Repo,
|
config :slide_life, SlideLife.Repo,
|
||||||
# ssl: true,
|
# ssl: true,
|
||||||
url: database_url,
|
url: database_url,
|
||||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
||||||
@ -51,9 +51,9 @@ if config_env() == :prod do
|
|||||||
host = System.get_env("PHX_HOST") || "example.com"
|
host = System.get_env("PHX_HOST") || "example.com"
|
||||||
port = String.to_integer(System.get_env("PORT") || "4000")
|
port = String.to_integer(System.get_env("PORT") || "4000")
|
||||||
|
|
||||||
config :modern_base, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
config :slide_life, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
||||||
|
|
||||||
config :modern_base, ModernBaseWeb.Endpoint,
|
config :slide_life, SlideLifeWeb.Endpoint,
|
||||||
url: [host: host, port: 443, scheme: "https"],
|
url: [host: host, port: 443, scheme: "https"],
|
||||||
http: [
|
http: [
|
||||||
# Enable IPv6 and bind on all interfaces.
|
# Enable IPv6 and bind on all interfaces.
|
||||||
@ -70,7 +70,7 @@ if config_env() == :prod do
|
|||||||
# To get SSL working, you will need to add the `https` key
|
# To get SSL working, you will need to add the `https` key
|
||||||
# to your endpoint configuration:
|
# to your endpoint configuration:
|
||||||
#
|
#
|
||||||
# config :modern_base, ModernBaseWeb.Endpoint,
|
# config :slide_life, SlideLifeWeb.Endpoint,
|
||||||
# https: [
|
# https: [
|
||||||
# ...,
|
# ...,
|
||||||
# port: 443,
|
# port: 443,
|
||||||
@ -92,7 +92,7 @@ if config_env() == :prod do
|
|||||||
# We also recommend setting `force_ssl` in your config/prod.exs,
|
# We also recommend setting `force_ssl` in your config/prod.exs,
|
||||||
# ensuring no data is ever sent via http, always redirecting to https:
|
# ensuring no data is ever sent via http, always redirecting to https:
|
||||||
#
|
#
|
||||||
# config :modern_base, ModernBaseWeb.Endpoint,
|
# config :slide_life, SlideLifeWeb.Endpoint,
|
||||||
# force_ssl: [hsts: true]
|
# force_ssl: [hsts: true]
|
||||||
#
|
#
|
||||||
# Check `Plug.SSL` for all available options in `force_ssl`.
|
# Check `Plug.SSL` for all available options in `force_ssl`.
|
||||||
@ -103,7 +103,7 @@ if config_env() == :prod do
|
|||||||
# Also, you may need to configure the Swoosh API client of your choice if you
|
# 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:
|
# are not using SMTP. Here is an example of the configuration:
|
||||||
#
|
#
|
||||||
# config :modern_base, ModernBase.Mailer,
|
# config :slide_life, SlideLife.Mailer,
|
||||||
# adapter: Swoosh.Adapters.Mailgun,
|
# adapter: Swoosh.Adapters.Mailgun,
|
||||||
# api_key: System.get_env("MAILGUN_API_KEY"),
|
# api_key: System.get_env("MAILGUN_API_KEY"),
|
||||||
# domain: System.get_env("MAILGUN_DOMAIN")
|
# domain: System.get_env("MAILGUN_DOMAIN")
|
||||||
|
@ -5,23 +5,23 @@ import Config
|
|||||||
# The MIX_TEST_PARTITION environment variable can be used
|
# The MIX_TEST_PARTITION environment variable can be used
|
||||||
# to provide built-in test partitioning in CI environment.
|
# to provide built-in test partitioning in CI environment.
|
||||||
# Run `mix help test` for more information.
|
# Run `mix help test` for more information.
|
||||||
config :modern_base, ModernBase.Repo,
|
config :slide_life, SlideLife.Repo,
|
||||||
username: "postgres",
|
username: "postgres",
|
||||||
password: "postgres",
|
password: "postgres",
|
||||||
hostname: "localhost",
|
hostname: "localhost",
|
||||||
database: "modern_base_test#{System.get_env("MIX_TEST_PARTITION")}",
|
database: "slide_life_test#{System.get_env("MIX_TEST_PARTITION")}",
|
||||||
pool: Ecto.Adapters.SQL.Sandbox,
|
pool: Ecto.Adapters.SQL.Sandbox,
|
||||||
pool_size: System.schedulers_online() * 2
|
pool_size: System.schedulers_online() * 2
|
||||||
|
|
||||||
# We don't run a server during test. If one is required,
|
# We don't run a server during test. If one is required,
|
||||||
# you can enable the server option below.
|
# you can enable the server option below.
|
||||||
config :modern_base, ModernBaseWeb.Endpoint,
|
config :slide_life, SlideLifeWeb.Endpoint,
|
||||||
http: [ip: {127, 0, 0, 1}, port: 4002],
|
http: [ip: {127, 0, 0, 1}, port: 4002],
|
||||||
secret_key_base: "Nrp7SlEOymCdvtNm/jLvYBfD9l+FZqQHTitjkVafLgxH22SEQXx3w2kjON2KsYFa",
|
secret_key_base: "Nrp7SlEOymCdvtNm/jLvYBfD9l+FZqQHTitjkVafLgxH22SEQXx3w2kjON2KsYFa",
|
||||||
server: false
|
server: false
|
||||||
|
|
||||||
# In test we don't send emails.
|
# In test we don't send emails.
|
||||||
config :modern_base, ModernBase.Mailer, adapter: Swoosh.Adapters.Test
|
config :slide_life, SlideLife.Mailer, adapter: Swoosh.Adapters.Test
|
||||||
|
|
||||||
# Disable swoosh api client as it is only required for production adapters.
|
# Disable swoosh api client as it is only required for production adapters.
|
||||||
config :swoosh, :api_client, false
|
config :swoosh, :api_client, false
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
defmodule ModernBase.Mailer do
|
|
||||||
use Swoosh.Mailer, otp_app: :modern_base
|
|
||||||
end
|
|
@ -1,6 +1,6 @@
|
|||||||
defmodule ModernBase do
|
defmodule SlideLife do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
ModernBase keeps the contexts that define your domain
|
SlideLife keeps the contexts that define your domain
|
||||||
and business logic.
|
and business logic.
|
||||||
|
|
||||||
Contexts are also responsible for managing your data, regardless
|
Contexts are also responsible for managing your data, regardless
|
@ -1,4 +1,4 @@
|
|||||||
defmodule ModernBase.Application do
|
defmodule SlideLife.Application do
|
||||||
# See https://hexdocs.pm/elixir/Application.html
|
# See https://hexdocs.pm/elixir/Application.html
|
||||||
# for more information on OTP Applications
|
# for more information on OTP Applications
|
||||||
@moduledoc false
|
@moduledoc false
|
||||||
@ -8,21 +8,21 @@ defmodule ModernBase.Application do
|
|||||||
@impl true
|
@impl true
|
||||||
def start(_type, _args) do
|
def start(_type, _args) do
|
||||||
children = [
|
children = [
|
||||||
ModernBaseWeb.Telemetry,
|
SlideLifeWeb.Telemetry,
|
||||||
ModernBase.Repo,
|
SlideLife.Repo,
|
||||||
{DNSCluster, query: Application.get_env(:modern_base, :dns_cluster_query) || :ignore},
|
{DNSCluster, query: Application.get_env(:slide_life, :dns_cluster_query) || :ignore},
|
||||||
{Phoenix.PubSub, name: ModernBase.PubSub},
|
{Phoenix.PubSub, name: SlideLife.PubSub},
|
||||||
# Start the Finch HTTP client for sending emails
|
# Start the Finch HTTP client for sending emails
|
||||||
{Finch, name: ModernBase.Finch},
|
{Finch, name: SlideLife.Finch},
|
||||||
# Start a worker by calling: ModernBase.Worker.start_link(arg)
|
# Start a worker by calling: SlideLife.Worker.start_link(arg)
|
||||||
# {ModernBase.Worker, arg},
|
# {SlideLife.Worker, arg},
|
||||||
# Start to serve requests, typically the last entry
|
# Start to serve requests, typically the last entry
|
||||||
ModernBaseWeb.Endpoint
|
SlideLifeWeb.Endpoint
|
||||||
]
|
]
|
||||||
|
|
||||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||||
# for other strategies and supported options
|
# for other strategies and supported options
|
||||||
opts = [strategy: :one_for_one, name: ModernBase.Supervisor]
|
opts = [strategy: :one_for_one, name: SlideLife.Supervisor]
|
||||||
Supervisor.start_link(children, opts)
|
Supervisor.start_link(children, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ defmodule ModernBase.Application do
|
|||||||
# whenever the application is updated.
|
# whenever the application is updated.
|
||||||
@impl true
|
@impl true
|
||||||
def config_change(changed, _new, removed) do
|
def config_change(changed, _new, removed) do
|
||||||
ModernBaseWeb.Endpoint.config_change(changed, removed)
|
SlideLifeWeb.Endpoint.config_change(changed, removed)
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
end
|
end
|
3
lib/slide_life/mailer.ex
Normal file
3
lib/slide_life/mailer.ex
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
defmodule SlideLife.Mailer do
|
||||||
|
use Swoosh.Mailer, otp_app: :slide_life
|
||||||
|
end
|
@ -1,5 +1,5 @@
|
|||||||
defmodule ModernBase.Repo do
|
defmodule SlideLife.Repo do
|
||||||
use Ecto.Repo,
|
use Ecto.Repo,
|
||||||
otp_app: :modern_base,
|
otp_app: :slide_life,
|
||||||
adapter: Ecto.Adapters.Postgres
|
adapter: Ecto.Adapters.Postgres
|
||||||
end
|
end
|
@ -1,12 +1,12 @@
|
|||||||
defmodule ModernBaseWeb do
|
defmodule SlideLifeWeb do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
The entrypoint for defining your web interface, such
|
The entrypoint for defining your web interface, such
|
||||||
as controllers, components, channels, and so on.
|
as controllers, components, channels, and so on.
|
||||||
|
|
||||||
This can be used in your application as:
|
This can be used in your application as:
|
||||||
|
|
||||||
use ModernBaseWeb, :controller
|
use SlideLifeWeb, :controller
|
||||||
use ModernBaseWeb, :html
|
use SlideLifeWeb, :html
|
||||||
|
|
||||||
The definitions below will be executed for every controller,
|
The definitions below will be executed for every controller,
|
||||||
component, etc, so keep them short and clean, focused
|
component, etc, so keep them short and clean, focused
|
||||||
@ -40,10 +40,10 @@ defmodule ModernBaseWeb do
|
|||||||
quote do
|
quote do
|
||||||
use Phoenix.Controller,
|
use Phoenix.Controller,
|
||||||
formats: [:html, :json],
|
formats: [:html, :json],
|
||||||
layouts: [html: ModernBaseWeb.Layouts]
|
layouts: [html: SlideLifeWeb.Layouts]
|
||||||
|
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
import ModernBaseWeb.Gettext
|
import SlideLifeWeb.Gettext
|
||||||
|
|
||||||
unquote(verified_routes())
|
unquote(verified_routes())
|
||||||
end
|
end
|
||||||
@ -52,7 +52,7 @@ defmodule ModernBaseWeb do
|
|||||||
def live_view do
|
def live_view do
|
||||||
quote do
|
quote do
|
||||||
use Phoenix.LiveView,
|
use Phoenix.LiveView,
|
||||||
layout: {ModernBaseWeb.Layouts, :app}
|
layout: {SlideLifeWeb.Layouts, :app}
|
||||||
|
|
||||||
unquote(html_helpers())
|
unquote(html_helpers())
|
||||||
end
|
end
|
||||||
@ -84,8 +84,8 @@ defmodule ModernBaseWeb do
|
|||||||
# HTML escaping functionality
|
# HTML escaping functionality
|
||||||
import Phoenix.HTML
|
import Phoenix.HTML
|
||||||
# Core UI components and translation
|
# Core UI components and translation
|
||||||
import ModernBaseWeb.CoreComponents
|
import SlideLifeWeb.CoreComponents
|
||||||
import ModernBaseWeb.Gettext
|
import SlideLifeWeb.Gettext
|
||||||
|
|
||||||
# Shortcut for generating JS commands
|
# Shortcut for generating JS commands
|
||||||
alias Phoenix.LiveView.JS
|
alias Phoenix.LiveView.JS
|
||||||
@ -98,9 +98,9 @@ defmodule ModernBaseWeb do
|
|||||||
def verified_routes do
|
def verified_routes do
|
||||||
quote do
|
quote do
|
||||||
use Phoenix.VerifiedRoutes,
|
use Phoenix.VerifiedRoutes,
|
||||||
endpoint: ModernBaseWeb.Endpoint,
|
endpoint: SlideLifeWeb.Endpoint,
|
||||||
router: ModernBaseWeb.Router,
|
router: SlideLifeWeb.Router,
|
||||||
statics: ModernBaseWeb.static_paths()
|
statics: SlideLifeWeb.static_paths()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
defmodule ModernBaseWeb.CoreComponents do
|
defmodule SlideLifeWeb.CoreComponents do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Provides core UI components.
|
Provides core UI components.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ defmodule ModernBaseWeb.CoreComponents do
|
|||||||
use Phoenix.Component
|
use Phoenix.Component
|
||||||
|
|
||||||
alias Phoenix.LiveView.JS
|
alias Phoenix.LiveView.JS
|
||||||
import ModernBaseWeb.Gettext
|
import SlideLifeWeb.Gettext
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Renders a modal.
|
Renders a modal.
|
||||||
@ -661,9 +661,9 @@ defmodule ModernBaseWeb.CoreComponents do
|
|||||||
# with our gettext backend as first argument. Translations are
|
# with our gettext backend as first argument. Translations are
|
||||||
# available in the errors.po file (as we use the "errors" domain).
|
# available in the errors.po file (as we use the "errors" domain).
|
||||||
if count = opts[:count] do
|
if count = opts[:count] do
|
||||||
Gettext.dngettext(ModernBaseWeb.Gettext, "errors", msg, msg, count, opts)
|
Gettext.dngettext(SlideLifeWeb.Gettext, "errors", msg, msg, count, opts)
|
||||||
else
|
else
|
||||||
Gettext.dgettext(ModernBaseWeb.Gettext, "errors", msg, opts)
|
Gettext.dgettext(SlideLifeWeb.Gettext, "errors", msg, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,14 +1,14 @@
|
|||||||
defmodule ModernBaseWeb.Layouts do
|
defmodule SlideLifeWeb.Layouts do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
This module holds different layouts used by your application.
|
This module holds different layouts used by your application.
|
||||||
|
|
||||||
See the `layouts` directory for all templates available.
|
See the `layouts` directory for all templates available.
|
||||||
The "root" layout is a skeleton rendered as part of the
|
The "root" layout is a skeleton rendered as part of the
|
||||||
application router. The "app" layout is set as the default
|
application router. The "app" layout is set as the default
|
||||||
layout on both `use ModernBaseWeb, :controller` and
|
layout on both `use SlideLifeWeb, :controller` and
|
||||||
`use ModernBaseWeb, :live_view`.
|
`use SlideLifeWeb, :live_view`.
|
||||||
"""
|
"""
|
||||||
use ModernBaseWeb, :html
|
use SlideLifeWeb, :html
|
||||||
|
|
||||||
embed_templates "layouts/*"
|
embed_templates "layouts/*"
|
||||||
end
|
end
|
@ -5,7 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="csrf-token" content={get_csrf_token()} />
|
<meta name="csrf-token" content={get_csrf_token()} />
|
||||||
<.live_title suffix=" · Phoenix Framework">
|
<.live_title suffix=" · Phoenix Framework">
|
||||||
<%= assigns[:page_title] || "ModernBase" %>
|
<%= assigns[:page_title] || "SlideLife" %>
|
||||||
</.live_title>
|
</.live_title>
|
||||||
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
||||||
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
|
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
|
@ -1,17 +1,17 @@
|
|||||||
defmodule ModernBaseWeb.ErrorHTML do
|
defmodule SlideLifeWeb.ErrorHTML do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
This module is invoked by your endpoint in case of errors on HTML requests.
|
This module is invoked by your endpoint in case of errors on HTML requests.
|
||||||
|
|
||||||
See config/config.exs.
|
See config/config.exs.
|
||||||
"""
|
"""
|
||||||
use ModernBaseWeb, :html
|
use SlideLifeWeb, :html
|
||||||
|
|
||||||
# If you want to customize your error pages,
|
# If you want to customize your error pages,
|
||||||
# uncomment the embed_templates/1 call below
|
# uncomment the embed_templates/1 call below
|
||||||
# and add pages to the error directory:
|
# and add pages to the error directory:
|
||||||
#
|
#
|
||||||
# * lib/modern_base_web/controllers/error_html/404.html.heex
|
# * lib/slide_life_web/controllers/error_html/404.html.heex
|
||||||
# * lib/modern_base_web/controllers/error_html/500.html.heex
|
# * lib/slide_life_web/controllers/error_html/500.html.heex
|
||||||
#
|
#
|
||||||
# embed_templates "error_html/*"
|
# embed_templates "error_html/*"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
defmodule ModernBaseWeb.ErrorJSON do
|
defmodule SlideLifeWeb.ErrorJSON do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
This module is invoked by your endpoint in case of errors on JSON requests.
|
This module is invoked by your endpoint in case of errors on JSON requests.
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
defmodule ModernBaseWeb.PageController do
|
defmodule SlideLifeWeb.PageController do
|
||||||
use ModernBaseWeb, :controller
|
use SlideLifeWeb, :controller
|
||||||
|
|
||||||
def home(conn, _params) do
|
def home(conn, _params) do
|
||||||
# The home page is often custom made,
|
# The home page is often custom made,
|
@ -1,10 +1,10 @@
|
|||||||
defmodule ModernBaseWeb.PageHTML do
|
defmodule SlideLifeWeb.PageHTML do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
This module contains pages rendered by PageController.
|
This module contains pages rendered by PageController.
|
||||||
|
|
||||||
See the `page_html` directory for all templates available.
|
See the `page_html` directory for all templates available.
|
||||||
"""
|
"""
|
||||||
use ModernBaseWeb, :html
|
use SlideLifeWeb, :html
|
||||||
|
|
||||||
embed_templates "page_html/*"
|
embed_templates "page_html/*"
|
||||||
end
|
end
|
@ -1,12 +1,12 @@
|
|||||||
defmodule ModernBaseWeb.Endpoint do
|
defmodule SlideLifeWeb.Endpoint do
|
||||||
use Phoenix.Endpoint, otp_app: :modern_base
|
use Phoenix.Endpoint, otp_app: :slide_life
|
||||||
|
|
||||||
# The session will be stored in the cookie and signed,
|
# The session will be stored in the cookie and signed,
|
||||||
# this means its contents can be read but not tampered with.
|
# this means its contents can be read but not tampered with.
|
||||||
# Set :encryption_salt if you would also like to encrypt it.
|
# Set :encryption_salt if you would also like to encrypt it.
|
||||||
@session_options [
|
@session_options [
|
||||||
store: :cookie,
|
store: :cookie,
|
||||||
key: "_modern_base_key",
|
key: "_slide_life_key",
|
||||||
signing_salt: "ExhFLciv",
|
signing_salt: "ExhFLciv",
|
||||||
same_site: "Lax"
|
same_site: "Lax"
|
||||||
]
|
]
|
||||||
@ -21,9 +21,9 @@ defmodule ModernBaseWeb.Endpoint do
|
|||||||
# when deploying your static files in production.
|
# when deploying your static files in production.
|
||||||
plug Plug.Static,
|
plug Plug.Static,
|
||||||
at: "/",
|
at: "/",
|
||||||
from: :modern_base,
|
from: :slide_life,
|
||||||
gzip: false,
|
gzip: false,
|
||||||
only: ModernBaseWeb.static_paths()
|
only: SlideLifeWeb.static_paths()
|
||||||
|
|
||||||
# Code reloading can be explicitly enabled under the
|
# Code reloading can be explicitly enabled under the
|
||||||
# :code_reloader configuration of your endpoint.
|
# :code_reloader configuration of your endpoint.
|
||||||
@ -31,7 +31,7 @@ defmodule ModernBaseWeb.Endpoint do
|
|||||||
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
|
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
|
||||||
plug Phoenix.LiveReloader
|
plug Phoenix.LiveReloader
|
||||||
plug Phoenix.CodeReloader
|
plug Phoenix.CodeReloader
|
||||||
plug Phoenix.Ecto.CheckRepoStatus, otp_app: :modern_base
|
plug Phoenix.Ecto.CheckRepoStatus, otp_app: :slide_life
|
||||||
end
|
end
|
||||||
|
|
||||||
plug Phoenix.LiveDashboard.RequestLogger,
|
plug Phoenix.LiveDashboard.RequestLogger,
|
||||||
@ -49,5 +49,5 @@ defmodule ModernBaseWeb.Endpoint do
|
|||||||
plug Plug.MethodOverride
|
plug Plug.MethodOverride
|
||||||
plug Plug.Head
|
plug Plug.Head
|
||||||
plug Plug.Session, @session_options
|
plug Plug.Session, @session_options
|
||||||
plug ModernBaseWeb.Router
|
plug SlideLifeWeb.Router
|
||||||
end
|
end
|
@ -1,11 +1,11 @@
|
|||||||
defmodule ModernBaseWeb.Gettext do
|
defmodule SlideLifeWeb.Gettext do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
A module providing Internationalization with a gettext-based API.
|
A module providing Internationalization with a gettext-based API.
|
||||||
|
|
||||||
By using [Gettext](https://hexdocs.pm/gettext),
|
By using [Gettext](https://hexdocs.pm/gettext),
|
||||||
your module gains a set of macros for translations, for example:
|
your module gains a set of macros for translations, for example:
|
||||||
|
|
||||||
import ModernBaseWeb.Gettext
|
import SlideLifeWeb.Gettext
|
||||||
|
|
||||||
# Simple translation
|
# Simple translation
|
||||||
gettext("Here is the string to translate")
|
gettext("Here is the string to translate")
|
||||||
@ -20,5 +20,5 @@ defmodule ModernBaseWeb.Gettext do
|
|||||||
|
|
||||||
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
|
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
|
||||||
"""
|
"""
|
||||||
use Gettext, otp_app: :modern_base
|
use Gettext, otp_app: :slide_life
|
||||||
end
|
end
|
@ -1,11 +1,11 @@
|
|||||||
defmodule ModernBaseWeb.Router do
|
defmodule SlideLifeWeb.Router do
|
||||||
use ModernBaseWeb, :router
|
use SlideLifeWeb, :router
|
||||||
|
|
||||||
pipeline :browser do
|
pipeline :browser do
|
||||||
plug :accepts, ["html"]
|
plug :accepts, ["html"]
|
||||||
plug :fetch_session
|
plug :fetch_session
|
||||||
plug :fetch_live_flash
|
plug :fetch_live_flash
|
||||||
plug :put_root_layout, html: {ModernBaseWeb.Layouts, :root}
|
plug :put_root_layout, html: {SlideLifeWeb.Layouts, :root}
|
||||||
plug :protect_from_forgery
|
plug :protect_from_forgery
|
||||||
plug :put_secure_browser_headers
|
plug :put_secure_browser_headers
|
||||||
end
|
end
|
||||||
@ -14,19 +14,19 @@ defmodule ModernBaseWeb.Router do
|
|||||||
plug :accepts, ["json"]
|
plug :accepts, ["json"]
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/", ModernBaseWeb do
|
scope "/", SlideLifeWeb do
|
||||||
pipe_through :browser
|
pipe_through :browser
|
||||||
|
|
||||||
get "/", PageController, :home
|
get "/", PageController, :home
|
||||||
end
|
end
|
||||||
|
|
||||||
# Other scopes may use custom stacks.
|
# Other scopes may use custom stacks.
|
||||||
# scope "/api", ModernBaseWeb do
|
# scope "/api", SlideLifeWeb do
|
||||||
# pipe_through :api
|
# pipe_through :api
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# Enable LiveDashboard and Swoosh mailbox preview in development
|
# Enable LiveDashboard and Swoosh mailbox preview in development
|
||||||
if Application.compile_env(:modern_base, :dev_routes) do
|
if Application.compile_env(:slide_life, :dev_routes) do
|
||||||
# If you want to use the LiveDashboard in production, you should put
|
# If you want to use the LiveDashboard in production, you should put
|
||||||
# it behind authentication and allow only admins to access it.
|
# it behind authentication and allow only admins to access it.
|
||||||
# If your application does not have an admins-only section yet,
|
# If your application does not have an admins-only section yet,
|
||||||
@ -37,7 +37,7 @@ defmodule ModernBaseWeb.Router do
|
|||||||
scope "/dev" do
|
scope "/dev" do
|
||||||
pipe_through :browser
|
pipe_through :browser
|
||||||
|
|
||||||
live_dashboard "/dashboard", metrics: ModernBaseWeb.Telemetry
|
live_dashboard "/dashboard", metrics: SlideLifeWeb.Telemetry
|
||||||
forward "/mailbox", Plug.Swoosh.MailboxPreview
|
forward "/mailbox", Plug.Swoosh.MailboxPreview
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
defmodule ModernBaseWeb.Telemetry do
|
defmodule SlideLifeWeb.Telemetry do
|
||||||
use Supervisor
|
use Supervisor
|
||||||
import Telemetry.Metrics
|
import Telemetry.Metrics
|
||||||
|
|
||||||
@ -52,23 +52,23 @@ defmodule ModernBaseWeb.Telemetry do
|
|||||||
),
|
),
|
||||||
|
|
||||||
# Database Metrics
|
# Database Metrics
|
||||||
summary("modern_base.repo.query.total_time",
|
summary("slide_life.repo.query.total_time",
|
||||||
unit: {:native, :millisecond},
|
unit: {:native, :millisecond},
|
||||||
description: "The sum of the other measurements"
|
description: "The sum of the other measurements"
|
||||||
),
|
),
|
||||||
summary("modern_base.repo.query.decode_time",
|
summary("slide_life.repo.query.decode_time",
|
||||||
unit: {:native, :millisecond},
|
unit: {:native, :millisecond},
|
||||||
description: "The time spent decoding the data received from the database"
|
description: "The time spent decoding the data received from the database"
|
||||||
),
|
),
|
||||||
summary("modern_base.repo.query.query_time",
|
summary("slide_life.repo.query.query_time",
|
||||||
unit: {:native, :millisecond},
|
unit: {:native, :millisecond},
|
||||||
description: "The time spent executing the query"
|
description: "The time spent executing the query"
|
||||||
),
|
),
|
||||||
summary("modern_base.repo.query.queue_time",
|
summary("slide_life.repo.query.queue_time",
|
||||||
unit: {:native, :millisecond},
|
unit: {:native, :millisecond},
|
||||||
description: "The time spent waiting for a database connection"
|
description: "The time spent waiting for a database connection"
|
||||||
),
|
),
|
||||||
summary("modern_base.repo.query.idle_time",
|
summary("slide_life.repo.query.idle_time",
|
||||||
unit: {:native, :millisecond},
|
unit: {:native, :millisecond},
|
||||||
description:
|
description:
|
||||||
"The time the connection spent waiting before being checked out for the query"
|
"The time the connection spent waiting before being checked out for the query"
|
||||||
@ -86,7 +86,7 @@ defmodule ModernBaseWeb.Telemetry do
|
|||||||
[
|
[
|
||||||
# A module, function and arguments to be invoked periodically.
|
# A module, function and arguments to be invoked periodically.
|
||||||
# This function must call :telemetry.execute/3 and a metric must be added above.
|
# This function must call :telemetry.execute/3 and a metric must be added above.
|
||||||
# {ModernBaseWeb, :count_users, []}
|
# {SlideLifeWeb, :count_users, []}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
12
mix.exs
12
mix.exs
@ -1,9 +1,9 @@
|
|||||||
defmodule ModernBase.MixProject do
|
defmodule SlideLife.MixProject do
|
||||||
use Mix.Project
|
use Mix.Project
|
||||||
|
|
||||||
def project do
|
def project do
|
||||||
[
|
[
|
||||||
app: :modern_base,
|
app: :slide_life,
|
||||||
version: "0.1.0",
|
version: "0.1.0",
|
||||||
elixir: "~> 1.14",
|
elixir: "~> 1.14",
|
||||||
elixirc_paths: elixirc_paths(Mix.env()),
|
elixirc_paths: elixirc_paths(Mix.env()),
|
||||||
@ -18,7 +18,7 @@ defmodule ModernBase.MixProject do
|
|||||||
# Type `mix help compile.app` for more information.
|
# Type `mix help compile.app` for more information.
|
||||||
def application do
|
def application do
|
||||||
[
|
[
|
||||||
mod: {ModernBase.Application, []},
|
mod: {SlideLife.Application, []},
|
||||||
extra_applications: [:logger, :runtime_tools]
|
extra_applications: [:logger, :runtime_tools]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
@ -74,10 +74,10 @@ defmodule ModernBase.MixProject do
|
|||||||
"ecto.reset": ["ecto.drop", "ecto.setup"],
|
"ecto.reset": ["ecto.drop", "ecto.setup"],
|
||||||
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
|
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
|
||||||
"assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"],
|
"assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"],
|
||||||
"assets.build": ["tailwind modern_base", "esbuild modern_base"],
|
"assets.build": ["tailwind slide_life", "esbuild slide_life"],
|
||||||
"assets.deploy": [
|
"assets.deploy": [
|
||||||
"tailwind modern_base --minify",
|
"tailwind slide_life --minify",
|
||||||
"esbuild modern_base --minify",
|
"esbuild slide_life --minify",
|
||||||
"phx.digest"
|
"phx.digest"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# Inside the script, you can read and write to any of your
|
# Inside the script, you can read and write to any of your
|
||||||
# repositories directly:
|
# repositories directly:
|
||||||
#
|
#
|
||||||
# ModernBase.Repo.insert!(%ModernBase.SomeSchema{})
|
# SlideLife.Repo.insert!(%SlideLife.SomeSchema{})
|
||||||
#
|
#
|
||||||
# We recommend using the bang functions (`insert!`, `update!`
|
# We recommend using the bang functions (`insert!`, `update!`
|
||||||
# and so on) as they will fail if something goes wrong.
|
# and so on) as they will fail if something goes wrong.
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
defmodule ModernBaseWeb.ErrorHTMLTest do
|
|
||||||
use ModernBaseWeb.ConnCase, async: true
|
|
||||||
|
|
||||||
# Bring render_to_string/4 for testing custom views
|
|
||||||
import Phoenix.Template
|
|
||||||
|
|
||||||
test "renders 404.html" do
|
|
||||||
assert render_to_string(ModernBaseWeb.ErrorHTML, "404", "html", []) == "Not Found"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "renders 500.html" do
|
|
||||||
assert render_to_string(ModernBaseWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,12 +0,0 @@
|
|||||||
defmodule ModernBaseWeb.ErrorJSONTest do
|
|
||||||
use ModernBaseWeb.ConnCase, async: true
|
|
||||||
|
|
||||||
test "renders 404" do
|
|
||||||
assert ModernBaseWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
|
|
||||||
end
|
|
||||||
|
|
||||||
test "renders 500" do
|
|
||||||
assert ModernBaseWeb.ErrorJSON.render("500.json", %{}) ==
|
|
||||||
%{errors: %{detail: "Internal Server Error"}}
|
|
||||||
end
|
|
||||||
end
|
|
14
test/slide_life_web/controllers/error_html_test.exs
Normal file
14
test/slide_life_web/controllers/error_html_test.exs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
defmodule SlideLifeWeb.ErrorHTMLTest do
|
||||||
|
use SlideLifeWeb.ConnCase, async: true
|
||||||
|
|
||||||
|
# Bring render_to_string/4 for testing custom views
|
||||||
|
import Phoenix.Template
|
||||||
|
|
||||||
|
test "renders 404.html" do
|
||||||
|
assert render_to_string(SlideLifeWeb.ErrorHTML, "404", "html", []) == "Not Found"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "renders 500.html" do
|
||||||
|
assert render_to_string(SlideLifeWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
|
||||||
|
end
|
||||||
|
end
|
12
test/slide_life_web/controllers/error_json_test.exs
Normal file
12
test/slide_life_web/controllers/error_json_test.exs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
defmodule SlideLifeWeb.ErrorJSONTest do
|
||||||
|
use SlideLifeWeb.ConnCase, async: true
|
||||||
|
|
||||||
|
test "renders 404" do
|
||||||
|
assert SlideLifeWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}}
|
||||||
|
end
|
||||||
|
|
||||||
|
test "renders 500" do
|
||||||
|
assert SlideLifeWeb.ErrorJSON.render("500.json", %{}) ==
|
||||||
|
%{errors: %{detail: "Internal Server Error"}}
|
||||||
|
end
|
||||||
|
end
|
@ -1,5 +1,5 @@
|
|||||||
defmodule ModernBaseWeb.PageControllerTest do
|
defmodule SlideLifeWeb.PageControllerTest do
|
||||||
use ModernBaseWeb.ConnCase
|
use SlideLifeWeb.ConnCase
|
||||||
|
|
||||||
test "GET /", %{conn: conn} do
|
test "GET /", %{conn: conn} do
|
||||||
conn = get(conn, ~p"/")
|
conn = get(conn, ~p"/")
|
@ -1,4 +1,4 @@
|
|||||||
defmodule ModernBaseWeb.ConnCase do
|
defmodule SlideLifeWeb.ConnCase do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
This module defines the test case to be used by
|
This module defines the test case to be used by
|
||||||
tests that require setting up a connection.
|
tests that require setting up a connection.
|
||||||
@ -11,7 +11,7 @@ defmodule ModernBaseWeb.ConnCase do
|
|||||||
we enable the SQL sandbox, so changes done to the database
|
we enable the SQL sandbox, so changes done to the database
|
||||||
are reverted at the end of every test. If you are using
|
are reverted at the end of every test. If you are using
|
||||||
PostgreSQL, you can even run database tests asynchronously
|
PostgreSQL, you can even run database tests asynchronously
|
||||||
by setting `use ModernBaseWeb.ConnCase, async: true`, although
|
by setting `use SlideLifeWeb.ConnCase, async: true`, although
|
||||||
this option is not recommended for other databases.
|
this option is not recommended for other databases.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -20,19 +20,19 @@ defmodule ModernBaseWeb.ConnCase do
|
|||||||
using do
|
using do
|
||||||
quote do
|
quote do
|
||||||
# The default endpoint for testing
|
# The default endpoint for testing
|
||||||
@endpoint ModernBaseWeb.Endpoint
|
@endpoint SlideLifeWeb.Endpoint
|
||||||
|
|
||||||
use ModernBaseWeb, :verified_routes
|
use SlideLifeWeb, :verified_routes
|
||||||
|
|
||||||
# Import conveniences for testing with connections
|
# Import conveniences for testing with connections
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
import Phoenix.ConnTest
|
import Phoenix.ConnTest
|
||||||
import ModernBaseWeb.ConnCase
|
import SlideLifeWeb.ConnCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
setup tags do
|
setup tags do
|
||||||
ModernBase.DataCase.setup_sandbox(tags)
|
SlideLife.DataCase.setup_sandbox(tags)
|
||||||
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
defmodule ModernBase.DataCase do
|
defmodule SlideLife.DataCase do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
This module defines the setup for tests requiring
|
This module defines the setup for tests requiring
|
||||||
access to the application's data layer.
|
access to the application's data layer.
|
||||||
@ -10,7 +10,7 @@ defmodule ModernBase.DataCase do
|
|||||||
we enable the SQL sandbox, so changes done to the database
|
we enable the SQL sandbox, so changes done to the database
|
||||||
are reverted at the end of every test. If you are using
|
are reverted at the end of every test. If you are using
|
||||||
PostgreSQL, you can even run database tests asynchronously
|
PostgreSQL, you can even run database tests asynchronously
|
||||||
by setting `use ModernBase.DataCase, async: true`, although
|
by setting `use SlideLife.DataCase, async: true`, although
|
||||||
this option is not recommended for other databases.
|
this option is not recommended for other databases.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -18,17 +18,17 @@ defmodule ModernBase.DataCase do
|
|||||||
|
|
||||||
using do
|
using do
|
||||||
quote do
|
quote do
|
||||||
alias ModernBase.Repo
|
alias SlideLife.Repo
|
||||||
|
|
||||||
import Ecto
|
import Ecto
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
import ModernBase.DataCase
|
import SlideLife.DataCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
setup tags do
|
setup tags do
|
||||||
ModernBase.DataCase.setup_sandbox(tags)
|
SlideLife.DataCase.setup_sandbox(tags)
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ defmodule ModernBase.DataCase do
|
|||||||
Sets up the sandbox based on the test tags.
|
Sets up the sandbox based on the test tags.
|
||||||
"""
|
"""
|
||||||
def setup_sandbox(tags) do
|
def setup_sandbox(tags) do
|
||||||
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(ModernBase.Repo, shared: not tags[:async])
|
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(SlideLife.Repo, shared: not tags[:async])
|
||||||
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
|
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
ExUnit.start()
|
ExUnit.start()
|
||||||
Ecto.Adapters.SQL.Sandbox.mode(ModernBase.Repo, :manual)
|
Ecto.Adapters.SQL.Sandbox.mode(SlideLife.Repo, :manual)
|
||||||
|
Reference in New Issue
Block a user