Skip to content

Commit a5116a2

Browse files
committed
Initial commit after generating new Phoenix app
Using `mix phoenix.new phoenix_react_redux_example --no-brunch --no-ecto`
0 parents  commit a5116a2

33 files changed

+1908
-0
lines changed

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# App artifacts
2+
/_build
3+
/db
4+
/deps
5+
/*.ez
6+
7+
# Generate on crash by the VM
8+
erl_crash.dump
9+
10+
# Static artifacts
11+
/node_modules
12+
13+
# The config/prod.secret.exs file by default contains sensitive
14+
# data and you should not commit it into version control.
15+
#
16+
# Alternatively, you may comment the line below and commit the
17+
# secrets file as long as you replace its contents by environment
18+
# variables.
19+
/config/prod.secret.exs

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Ben Smith
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Phoenix + React + Redux Example
2+
3+
Heavily inspired by @[ryanswapp](https://github.com/ryanswapp)'s [elixir-react-redux-example](https://github.com/ryanswapp/elixir-react-redux-example).
4+
5+
## Phoenix quickstart guide
6+
7+
To start your Phoenix app:
8+
9+
1. Install dependencies with `mix deps.get`
10+
2. Start Phoenix endpoint with `mix phoenix.server`
11+
12+
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.

config/config.exs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is responsible for configuring your application
2+
# and its dependencies with the aid of the Mix.Config module.
3+
#
4+
# This configuration file is loaded before any dependency and
5+
# is restricted to this project.
6+
use Mix.Config
7+
8+
# Configures the endpoint
9+
config :phoenix_react_redux_example, PhoenixReactReduxExample.Endpoint,
10+
url: [host: "localhost"],
11+
root: Path.dirname(__DIR__),
12+
secret_key_base: "sEE3bU6zBp2GSnxhod9D2JJyJlsM/IEfhe7FkWLzMleHiJmlawIILFtM/egm9c29",
13+
render_errors: [accepts: ~w(html json)],
14+
pubsub: [name: PhoenixReactReduxExample.PubSub,
15+
adapter: Phoenix.PubSub.PG2]
16+
17+
# Configures Elixir's Logger
18+
config :logger, :console,
19+
format: "$time $metadata[$level] $message\n",
20+
metadata: [:request_id]
21+
22+
# Import environment specific config. This must remain at the bottom
23+
# of this file so it overrides the configuration defined above.
24+
import_config "#{Mix.env}.exs"

config/dev.exs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use Mix.Config
2+
3+
# For development, we disable any cache and enable
4+
# debugging and code reloading.
5+
#
6+
# The watchers configuration can be used to run external
7+
# watchers to your application. For example, we use it
8+
# with brunch.io to recompile .js and .css sources.
9+
config :phoenix_react_redux_example, PhoenixReactReduxExample.Endpoint,
10+
http: [port: 4000],
11+
debug_errors: true,
12+
code_reloader: true,
13+
cache_static_lookup: false,
14+
check_origin: false,
15+
watchers: []
16+
17+
# Watch static and templates for browser reloading.
18+
config :phoenix_react_redux_example, PhoenixReactReduxExample.Endpoint,
19+
live_reload: [
20+
patterns: [
21+
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
22+
~r{web/views/.*(ex)$},
23+
~r{web/templates/.*(eex)$}
24+
]
25+
]
26+
27+
# Do not include metadata nor timestamps in development logs
28+
config :logger, :console, format: "[$level] $message\n"
29+
30+
# Set a higher stacktrace during development.
31+
# Do not configure such in production as keeping
32+
# and calculating stacktraces is usually expensive.
33+
config :phoenix, :stacktrace_depth, 20

config/prod.exs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
use Mix.Config
2+
3+
# For production, we configure the host to read the PORT
4+
# from the system environment. Therefore, you will need
5+
# to set PORT=80 before running your server.
6+
#
7+
# You should also configure the url host to something
8+
# meaningful, we use this information when generating URLs.
9+
#
10+
# Finally, we also include the path to a manifest
11+
# containing the digested version of static files. This
12+
# manifest is generated by the mix phoenix.digest task
13+
# which you typically run after static files are built.
14+
config :phoenix_react_redux_example, PhoenixReactReduxExample.Endpoint,
15+
http: [port: {:system, "PORT"}],
16+
url: [host: "example.com", port: 80],
17+
cache_static_manifest: "priv/static/manifest.json"
18+
19+
# Do not print debug messages in production
20+
config :logger, level: :info
21+
22+
# ## SSL Support
23+
#
24+
# To get SSL working, you will need to add the `https` key
25+
# to the previous section and set your `:url` port to 443:
26+
#
27+
# config :phoenix_react_redux_example, PhoenixReactReduxExample.Endpoint,
28+
# ...
29+
# url: [host: "example.com", port: 443],
30+
# https: [port: 443,
31+
# keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
32+
# certfile: System.get_env("SOME_APP_SSL_CERT_PATH")]
33+
#
34+
# Where those two env variables return an absolute path to
35+
# the key and cert in disk or a relative path inside priv,
36+
# for example "priv/ssl/server.key".
37+
#
38+
# We also recommend setting `force_ssl`, ensuring no data is
39+
# ever sent via http, always redirecting to https:
40+
#
41+
# config :phoenix_react_redux_example, PhoenixReactReduxExample.Endpoint,
42+
# force_ssl: [hsts: true]
43+
#
44+
# Check `Plug.SSL` for all available options in `force_ssl`.
45+
46+
# ## Using releases
47+
#
48+
# If you are doing OTP releases, you need to instruct Phoenix
49+
# to start the server for all endpoints:
50+
#
51+
# config :phoenix, :serve_endpoints, true
52+
#
53+
# Alternatively, you can configure exactly which server to
54+
# start per endpoint:
55+
#
56+
# config :phoenix_react_redux_example, PhoenixReactReduxExample.Endpoint, server: true
57+
#
58+
59+
# Finally import the config/prod.secret.exs
60+
# which should be versioned separately.
61+
import_config "prod.secret.exs"

config/test.exs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use Mix.Config
2+
3+
# We don't run a server during test. If one is required,
4+
# you can enable the server option below.
5+
config :phoenix_react_redux_example, PhoenixReactReduxExample.Endpoint,
6+
http: [port: 4001],
7+
server: false
8+
9+
# Print only warnings and errors during test
10+
config :logger, level: :warn

lib/phoenix_react_redux_example.ex

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
defmodule PhoenixReactReduxExample do
2+
use Application
3+
4+
# See http://elixir-lang.org/docs/stable/elixir/Application.html
5+
# for more information on OTP Applications
6+
def start(_type, _args) do
7+
import Supervisor.Spec, warn: false
8+
9+
children = [
10+
# Start the endpoint when the application starts
11+
supervisor(PhoenixReactReduxExample.Endpoint, []),
12+
# Here you could define other workers and supervisors as children
13+
# worker(PhoenixReactReduxExample.Worker, [arg1, arg2, arg3]),
14+
]
15+
16+
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
17+
# for other strategies and supported options
18+
opts = [strategy: :one_for_one, name: PhoenixReactReduxExample.Supervisor]
19+
Supervisor.start_link(children, opts)
20+
end
21+
22+
# Tell Phoenix to update the endpoint configuration
23+
# whenever the application is updated.
24+
def config_change(changed, _new, removed) do
25+
PhoenixReactReduxExample.Endpoint.config_change(changed, removed)
26+
:ok
27+
end
28+
end
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
defmodule PhoenixReactReduxExample.Endpoint do
2+
use Phoenix.Endpoint, otp_app: :phoenix_react_redux_example
3+
4+
socket "/socket", PhoenixReactReduxExample.UserSocket
5+
6+
# Serve at "/" the static files from "priv/static" directory.
7+
#
8+
# You should set gzip to true if you are running phoenix.digest
9+
# when deploying your static files in production.
10+
plug Plug.Static,
11+
at: "/", from: :phoenix_react_redux_example, gzip: false,
12+
only: ~w(css fonts images js favicon.ico robots.txt)
13+
14+
# Code reloading can be explicitly enabled under the
15+
# :code_reloader configuration of your endpoint.
16+
if code_reloading? do
17+
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
18+
plug Phoenix.LiveReloader
19+
plug Phoenix.CodeReloader
20+
end
21+
22+
plug Plug.RequestId
23+
plug Plug.Logger
24+
25+
plug Plug.Parsers,
26+
parsers: [:urlencoded, :multipart, :json],
27+
pass: ["*/*"],
28+
json_decoder: Poison
29+
30+
plug Plug.MethodOverride
31+
plug Plug.Head
32+
33+
plug Plug.Session,
34+
store: :cookie,
35+
key: "_phoenix_react_redux_example_key",
36+
signing_salt: "PQVeJMy/"
37+
38+
plug PhoenixReactReduxExample.Router
39+
end

mix.exs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
defmodule PhoenixReactReduxExample.Mixfile do
2+
use Mix.Project
3+
4+
def project do
5+
[app: :phoenix_react_redux_example,
6+
version: "0.0.1",
7+
elixir: "~> 1.0",
8+
elixirc_paths: elixirc_paths(Mix.env),
9+
compilers: [:phoenix] ++ Mix.compilers,
10+
build_embedded: Mix.env == :prod,
11+
start_permanent: Mix.env == :prod,
12+
deps: deps]
13+
end
14+
15+
# Configuration for the OTP application.
16+
#
17+
# Type `mix help compile.app` for more information.
18+
def application do
19+
[mod: {PhoenixReactReduxExample, []},
20+
applications: [:phoenix, :phoenix_html, :cowboy, :logger]]
21+
end
22+
23+
# Specifies which paths to compile per environment.
24+
defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
25+
defp elixirc_paths(_), do: ["lib", "web"]
26+
27+
# Specifies your project dependencies.
28+
#
29+
# Type `mix help deps` for examples and options.
30+
defp deps do
31+
[{:phoenix, "~> 1.0.3"},
32+
{:phoenix_html, "~> 2.1"},
33+
{:phoenix_live_reload, "~> 1.0", only: :dev},
34+
{:cowboy, "~> 1.0"}]
35+
end
36+
end

0 commit comments

Comments
 (0)