To start your Phoenix server:
- Install dependencies with
mix deps.get
- Create and migrate your database with
mix ecto.setup
- Start Phoenix endpoint with
mix phx.server
Now you can visit localhost:4000
from your browser.
Ready to run in production? Please check our deployment guides.
- Official website: https://www.phoenixframework.org/
- Guides: https://hexdocs.pm/phoenix/overview.html
- Docs: https://hexdocs.pm/phoenix
- Forum: https://elixirforum.com/c/phoenix-forum
- Source: https://github.com/phoenixframework/phoenix
mix phx.new rocktpay --no-webpack --no-html
# No use front-end tech's
mix ecto.setup
The file mix.exs is the configuration of all project The extension Elixir Linter and other we need a lib Credo
# mix.exs
defp deps do
[
{:phoenix, "~> 1.5.7"},
{:phoenix_ecto, "~> 4.1"},
{:ecto_sql, "~> 3.4"},
{:postgrex, ">= 0.0.0"},
{:phoenix_live_dashboard, "~> 0.4"},
{:telemetry_metrics, "~> 0.4"},
{:telemetry_poller, "~> 0.4"},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},
{:credo, "~> 1.5", only: [:dev, :test], runtime: false} # Include this row
]
end
mix deps.get
mix credo gen.config
As we dont worry with documentation, we need disable a config .credo.exs
{Credo.Check.Readability.ModuleDoc, false}, # Update this row
mix phx.server
- rocketpay -> logical and rules system
- rocketpay_web -> all we need to build a web system
In file router.ex
get "/", WelcomeController, :index
We created a route '/', that call the WelcomeController that its function is index
Now we gonna create the controller welocome_controller.ex
We need define the module
defmodule RocktpayWeb.WelcomeController do
it's necessary considerer special file, 'cause is a controller
use RocktpayWeb, :controller
Create de action index
def index(conn, _params)
File.read("#{filename}.csv")
iex
iex -S mix
defp handle_file({:ok, file}), do file
if the params is :ok, this return the file
mix exto.create
mix ecto.gen.migration create_user_table
mix ecto.migrate
mix ecto.drop
config :rocktpay, Rocktpay.Repo,
migration_primary_key: [type: :binary_id],
migration_foreing_key: [type: :binary_id]
mix ecto.gen.migration create_accounts_table
At iex if use Rocktpay.Repo.all(Rocktpay.User)
-> get all User database
test to account
params = %{user_id: "be7a4e5b-8a9d-4acf-8557-2cdf2c6a0c25", balance: "0.00"}
params |> Rocktpay.Account.changeset() |> Rocktpay.Repo.insert()
Rocktpay.Repo.all(Rocktpay.User) |> Rocktpay.Repo.preload(:account) # load with account
give multi transactions
In basic, set Basic Auth and insert the username and password
In Header:
- Content Type: Authorization
- application/json: Basic username:password
remembet that the username:password should be base64
In iex we can convert to this type:
Base.encode64("banana:nanica123")
"YmFuYW5hOm5hbmljYTEyMw=="
Basic YmFuYW5hOm5hbmljYTEyMw==
mix test --cover
mix coveralls.html
-> Create report html