Skip to content

Commit

Permalink
Chore: working surrealdb example
Browse files Browse the repository at this point in the history
  • Loading branch information
mindreframer committed Jan 23, 2024
1 parent d12390f commit efa3e70
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### SurrealDB
SURREALDB_PORT=8000
SURREALDB_HOST=localhost
SURREALDB_USER=root
SURREALDB_PASS=root
SURREALDB_NS=demo
SURREALDB_DB=demo
11 changes: 11 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ if System.get_env("PHX_SERVER") do
config :surrealix_demo, SurrealixDemoWeb.Endpoint, server: true
end

dot_env_path = Path.expand(Path.join(__DIR__, "../.env"))

if config_env() == :dev do
DotenvParser.load_file(dot_env_path)
config :logger, level: :debug
end

if config_env() == :test do
DotenvParser.load_file(dot_env_path)
end

if config_env() == :prod do
database_url =
System.get_env("DATABASE_URL") ||
Expand Down
6 changes: 6 additions & 0 deletions lib/surrealix_demo/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ defmodule SurrealixDemo.Application do
{Finch, name: SurrealixDemo.Finch},
# Start a worker by calling: SurrealixDemo.Worker.start_link(arg)
# {SurrealixDemo.Worker, arg},

## For SurrealDB
{Surreal.ClientSupervisor, []},
{Surreal.ConnSupervisor, []},
%{id: Surreal.Repo, start: {Surreal.Repo, :start_link, [[]]}},

# Start to serve requests, typically the last entry
SurrealixDemoWeb.Endpoint
]
Expand Down
3 changes: 3 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ defmodule SurrealixDemo.MixProject do
{:dns_cluster, "~> 0.1.1"},
{:plug_cowboy, "~> 2.5"},

# Misc
{:dotenv_parser, "~> 2.0"},

## DB - SurrealDB
{:surrealix, "~> 0.1"},
{:token_operator, "~> 0.3.1"}
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"db_connection": {:hex, :db_connection, "2.6.0", "77d835c472b5b67fc4f29556dee74bf511bbafecdcaf98c27d27fa5918152086", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c2f992d15725e721ec7fbc1189d4ecdb8afef76648c746a8e1cad35e3b8a35f3"},
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
"dns_cluster": {:hex, :dns_cluster, "0.1.2", "3eb5be824c7888dadf9781018e1a5f1d3d1113b333c50bce90fb1b83df1015f2", [:mix], [], "hexpm", "7494272040f847637bbdb01bcdf4b871e82daf09b813e7d3cb3b84f112c6f2f8"},
"dotenv_parser": {:hex, :dotenv_parser, "2.0.0", "0f999196857e4ee18cbba1413018d5e4980ab16b397e3a2f8d0cf541fe683181", [:mix], [], "hexpm", "e769bde2dbff5b0cd0d9d877a9ccfd2c6dd84772dfb405d5a43cceb4f93616c5"},
"ecto": {:hex, :ecto, "3.11.1", "4b4972b717e7ca83d30121b12998f5fcdc62ba0ed4f20fd390f16f3270d85c3e", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ebd3d3772cd0dfcd8d772659e41ed527c28b2a8bde4b00fe03e0463da0f1983b"},
"ecto_sql": {:hex, :ecto_sql, "3.11.1", "e9abf28ae27ef3916b43545f9578b4750956ccea444853606472089e7d169470", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.11.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.6.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.16.0 or ~> 0.17.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ce14063ab3514424276e7e360108ad6c2308f6d88164a076aac8a387e1fea634"},
"esbuild": {:hex, :esbuild, "0.8.1", "0cbf919f0eccb136d2eeef0df49c4acf55336de864e63594adcea3814f3edf41", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "25fc876a67c13cb0a776e7b5d7974851556baeda2085296c14ab48555ea7560f"},
Expand Down

0 comments on commit efa3e70

Please sign in to comment.