From f3bd838a61df21fbb4aff15e182c22388099c11e Mon Sep 17 00:00:00 2001 From: Burgy Benjamin Date: Tue, 5 Dec 2023 21:12:44 +0100 Subject: [PATCH] Rename the project because it will have more responsibilities. --- .gitignore | 2 +- Dockerfile | 6 +++--- README.md | 16 +++++++++------- config/config.exs | 8 ++++---- config/dev.exs | 4 ++-- config/runtime.exs | 16 ++++++++-------- config/test.exs | 2 +- docker-compose.yml | 6 +++--- lib/{kdrive_bridge.ex => ksuite_middleware.ex} | 4 ++-- .../application.ex | 18 +++++++++--------- .../ksuite_client.ex} | 10 +++++----- ..._bridge_web.ex => ksuite_middleware_web.ex} | 14 +++++++------- .../controllers/error_json.ex | 2 +- .../controllers/main_controller.ex | 16 ++++++++-------- .../endpoint.ex | 12 ++++++------ .../router.ex | 14 +++++++------- .../telemetry.ex | 4 ++-- mix.exs | 8 ++++---- mix.lock | 7 +++++++ priv/static/bad-api-key.html | 5 +++-- priv/static/index.html | 4 ++-- priv/static/not-found.html | 4 ++-- rel/overlays/bin/server | 2 +- rel/overlays/bin/server.bat | 2 +- .../controllers/error_json_test.exs | 12 ------------ .../controllers/error_json_test.exs | 12 ++++++++++++ .../controllers/home_controller_test.exs | 6 +++--- test/support/conn_case.ex | 10 +++++----- 28 files changed, 118 insertions(+), 108 deletions(-) rename lib/{kdrive_bridge.ex => ksuite_middleware.ex} (65%) rename lib/{kdrive_bridge => ksuite_middleware}/application.ex (52%) rename lib/{kdrive_bridge/kdrive_client.ex => ksuite_middleware/ksuite_client.ex} (71%) rename lib/{kdrive_bridge_web.ex => ksuite_middleware_web.ex} (80%) rename lib/{kdrive_bridge_web => ksuite_middleware_web}/controllers/error_json.ex (91%) rename lib/{kdrive_bridge_web => ksuite_middleware_web}/controllers/main_controller.ex (74%) rename lib/{kdrive_bridge_web => ksuite_middleware_web}/endpoint.ex (83%) rename lib/{kdrive_bridge_web => ksuite_middleware_web}/router.ex (73%) rename lib/{kdrive_bridge_web => ksuite_middleware_web}/telemetry.ex (95%) delete mode 100644 test/kdrive_bridge_web/controllers/error_json_test.exs create mode 100644 test/ksuite_middleware_web/controllers/error_json_test.exs rename test/{kdrive_bridge_web => ksuite_middleware_web}/controllers/home_controller_test.exs (94%) diff --git a/.gitignore b/.gitignore index 319eaef..3ae8640 100644 --- a/.gitignore +++ b/.gitignore @@ -23,5 +23,5 @@ erl_crash.dump /tmp/ # Ignore package tarball (built via "mix hex.build"). -kdrive_bridge-*.tar +ksuite_middleware-*.tar diff --git a/Dockerfile b/Dockerfile index d7f5e66..4f7b695 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,14 +22,14 @@ FROM ${BUILDER_IMAGE} as builder # install build dependencies RUN apt-get update -y && apt-get install -y build-essential git \ - && apt-get clean && rm -f /var/lib/apt/lists/*_* + && apt-get clean && rm -f /var/lib/apt/lists/*_* # prepare build dir WORKDIR /app # install hex + rebar RUN mix local.hex --force && \ - mix local.rebar --force + mix local.rebar --force # set build ENV ENV MIX_ENV="prod" @@ -80,7 +80,7 @@ RUN chown nobody /app ENV MIX_ENV="prod" # Only copy the final release from the build stage -COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/kdrive_bridge ./ +COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/ksuite_middleware ./ USER nobody diff --git a/README.md b/README.md index fd546a4..a886be4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ -# KdriveBridge +# Ksuite-middleware -The goal of this project is to provide access to the content of your files saved in kDrive without the KSuite layer by calling the URL: +Project providing a single endpoint with a single API configuration to access to many resources from a KSuite environment. + +## Kdrive ``` http://localhost:4000/files/ @@ -11,7 +13,7 @@ http://localhost:4000/files/ | Environment variables | Description | |-----------------------|------------------------------------------------------------------------------------------------------------------------------| | KDRIVE_ID | The identifier of your KDrive. | -| KDRIVE_API_TOKEN | The API token to use the KDrive API. | +| KSUITE_API_TOKEN | The API token to use the KDrive API. | | PHX_HOST | The host the web server. (default: example.com) | | PORT | The port for the web server. (default: 4000) | | SECRET_KEY_BASE | Secret key used by the [phoenix framework](https://hexdocs.pm/phoenix/deployment.html#handling-of-your-application-secrets). | @@ -19,21 +21,21 @@ http://localhost:4000/files/ ```yaml version: '3' services: - kdrive-bridge: - image: minidfx/kdrive-bridge:v0.3.0 + ksuite-middleware: + image: minidfx/ksuite-middleware:v0.4.0 environment: - SECRET_KEY_BASE= - PHX_HOST= - PORT= - KDRIVE_ID= - - KDRIVE_API_TOKEN= + - KSUITE_API_TOKEN= ports: - 4000:4000 ``` ## Running with Docker (recommended way) -With Docker, running the application is a breeze. Simply update the environment variables SECRET_KEY_BASE, PHX_HOST, KDRIVE_ID, and KDRIVE_API_TOKEN. Then, run it to kickstart the application. +With Docker, running the application is a breeze. Simply update the environment variables SECRET_KEY_BASE, PHX_HOST, KDRIVE_ID, and KSUITE_API_TOKEN. Then, run it to kickstart the application. ```bash docker-compose up diff --git a/config/config.exs b/config/config.exs index 3b71776..44dd233 100644 --- a/config/config.exs +++ b/config/config.exs @@ -7,18 +7,18 @@ # General application configuration import Config -config :kdrive_bridge, +config :ksuite_middleware, generators: [timestamp_type: :utc_datetime] # Configures the endpoint -config :kdrive_bridge, KdriveBridgeWeb.Endpoint, +config :ksuite_middleware, KsuiteMiddlewareWeb.Endpoint, url: [host: "localhost"], adapter: Phoenix.Endpoint.Cowboy2Adapter, render_errors: [ - formats: [json: KdriveBridgeWeb.ErrorJSON], + formats: [json: KsuiteMiddlewareWeb.ErrorJSON], layout: false ], - pubsub_server: KdriveBridge.PubSub, + pubsub_server: KsuiteMiddleware.PubSub, live_view: [signing_salt: "7nfCI6sX"] # Configures Elixir's Logger diff --git a/config/dev.exs b/config/dev.exs index 686dacd..c4dafd5 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -6,7 +6,7 @@ import Config # 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 :kdrive_bridge, KdriveBridgeWeb.Endpoint, +config :ksuite_middleware, KsuiteMiddlewareWeb.Endpoint, # Binding to loopback ipv4 address prevents access from other machines. # Change to `ip: {0, 0, 0, 0}` to allow access from other machines. http: [ip: {0, 0, 0, 0}, port: 4000], @@ -40,7 +40,7 @@ config :kdrive_bridge, KdriveBridgeWeb.Endpoint, # different ports. # Enable dev routes for dashboard and mailbox -config :kdrive_bridge, dev_routes: true +config :ksuite_middleware, dev_routes: true # Do not include metadata nor timestamps in development logs config :logger, :console, format: "[$level] $message\n" diff --git a/config/runtime.exs b/config/runtime.exs index a18916e..8e7ca0f 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -12,12 +12,12 @@ import Config # If you use `mix release`, you need to explicitly enable the server # by passing the PHX_SERVER=true when you start it: # -# PHX_SERVER=true bin/kdrive_bridge start +# PHX_SERVER=true bin/ksuite_middleware start # # Alternatively, you can use `mix phx.gen.release` to generate a `bin/server` # script that automatically sets the env var above. if System.get_env("PHX_SERVER") do - config :kdrive_bridge, KdriveBridgeWeb.Endpoint, server: true + config :ksuite_middleware, KsuiteMiddlewareWeb.Endpoint, server: true end if config_env() == :prod do @@ -36,9 +36,9 @@ if config_env() == :prod do host = System.get_env("PHX_HOST") || "example.com" port = String.to_integer(System.get_env("PORT") || "4000") - config :kdrive_bridge, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") + config :ksuite_middleware, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") - config :kdrive_bridge, KdriveBridgeWeb.Endpoint, + config :ksuite_middleware, KsuiteMiddlewareWeb.Endpoint, url: [host: host, port: 443, scheme: "http"], http: [ # Enable IPv6 and bind on all interfaces. @@ -50,16 +50,16 @@ if config_env() == :prod do ], secret_key_base: secret_key_base - config :kdrive_bridge, + config :ksuite_middleware, kdrive_id: System.get_env("KDRIVE_ID") || raise("The KDRIVE_ID variable was missing"), - kdrive_api_token: System.get_env("KDRIVE_API_TOKEN") || raise("The KDRIVE_API_TOKEN variable was missing") + ksuite_api_token: System.get_env("KSUITE_API_TOKEN") || raise("The KSUITE_API_TOKEN variable was missing") # ## SSL Support # # To get SSL working, you will need to add the `https` key # to your endpoint configuration: # - # config :kdrive_bridge, KdriveBridgeWeb.Endpoint, + # config :ksuite_middleware, KsuiteMiddlewareWeb.Endpoint, # https: [ # ..., # port: 443, @@ -81,7 +81,7 @@ if config_env() == :prod do # We also recommend setting `force_ssl` in your endpoint, ensuring # no data is ever sent via http, always redirecting to https: # - # config :kdrive_bridge, KdriveBridgeWeb.Endpoint, + # config :ksuite_middleware, KsuiteMiddlewareWeb.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. diff --git a/config/test.exs b/config/test.exs index 14f1b2f..7ee4481 100644 --- a/config/test.exs +++ b/config/test.exs @@ -2,7 +2,7 @@ import Config # We don't run a server during test. If one is required, # you can enable the server option below. -config :kdrive_bridge, KdriveBridgeWeb.Endpoint, +config :ksuite_middleware, KsuiteMiddlewareWeb.Endpoint, http: [ip: {127, 0, 0, 1}, port: 4002], secret_key_base: "BQY9JpU3sNCk28WVxTGzJMma6M4DIiMD+4L/OskOMPSgOXp08t6OBveo2ccdxYxr", server: false diff --git a/docker-compose.yml b/docker-compose.yml index 2213433..b699e81 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,13 @@ version: '3' services: - kdrive-bridge: + ksuite-middleware: build: . - image: minidfx/kdrive-bridge:v0.3.0 + image: minidfx/ksuite-middleware:v0.4.0 environment: - SECRET_KEY_BASE= - PHX_HOST= - PORT= - KDRIVE_ID= - - KDRIVE_API_TOKEN= + - KSUITE_API_TOKEN= ports: - 4000:4000 diff --git a/lib/kdrive_bridge.ex b/lib/ksuite_middleware.ex similarity index 65% rename from lib/kdrive_bridge.ex rename to lib/ksuite_middleware.ex index 5f2f4b5..4632d51 100644 --- a/lib/kdrive_bridge.ex +++ b/lib/ksuite_middleware.ex @@ -1,6 +1,6 @@ -defmodule KdriveBridge do +defmodule KsuiteMiddleware do @moduledoc """ - KdriveBridge keeps the contexts that define your domain + KsuiteMiddleware keeps the contexts that define your domain and business logic. Contexts are also responsible for managing your data, regardless diff --git a/lib/kdrive_bridge/application.ex b/lib/ksuite_middleware/application.ex similarity index 52% rename from lib/kdrive_bridge/application.ex rename to lib/ksuite_middleware/application.ex index 169a2ee..f63afd8 100644 --- a/lib/kdrive_bridge/application.ex +++ b/lib/ksuite_middleware/application.ex @@ -1,4 +1,4 @@ -defmodule KdriveBridge.Application do +defmodule KsuiteMiddleware.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false @@ -8,18 +8,18 @@ defmodule KdriveBridge.Application do @impl true def start(_type, _args) do children = [ - KdriveBridgeWeb.Telemetry, - {DNSCluster, query: Application.get_env(:kdrive_bridge, :dns_cluster_query) || :ignore}, - {Phoenix.PubSub, name: KdriveBridge.PubSub}, - # Start a worker by calling: KdriveBridge.Worker.start_link(arg) - # {KdriveBridge.Worker, arg}, + KsuiteMiddlewareWeb.Telemetry, + {DNSCluster, query: Application.get_env(:ksuite_middleware, :dns_cluster_query) || :ignore}, + {Phoenix.PubSub, name: KsuiteMiddleware.PubSub}, + # Start a worker by calling: KsuiteMiddleware.Worker.start_link(arg) + # {KsuiteMiddleware.Worker, arg}, # Start to serve requests, typically the last entry - KdriveBridgeWeb.Endpoint + KsuiteMiddlewareWeb.Endpoint ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options - opts = [strategy: :one_for_one, name: KdriveBridge.Supervisor] + opts = [strategy: :one_for_one, name: KsuiteMiddleware.Supervisor] Supervisor.start_link(children, opts) end @@ -27,7 +27,7 @@ defmodule KdriveBridge.Application do # whenever the application is updated. @impl true def config_change(changed, _new, removed) do - KdriveBridgeWeb.Endpoint.config_change(changed, removed) + KsuiteMiddlewareWeb.Endpoint.config_change(changed, removed) :ok end end diff --git a/lib/kdrive_bridge/kdrive_client.ex b/lib/ksuite_middleware/ksuite_client.ex similarity index 71% rename from lib/kdrive_bridge/kdrive_client.ex rename to lib/ksuite_middleware/ksuite_client.ex index b2b54f6..b3b1cdf 100644 --- a/lib/kdrive_bridge/kdrive_client.ex +++ b/lib/ksuite_middleware/ksuite_client.ex @@ -1,23 +1,23 @@ -defmodule KdriveBridge.KdriveClient do +defmodule KsuiteMiddleware.KsuiteClient do require Logger use Tesla plug Tesla.Middleware.BaseUrl, "https://api.infomaniak.com" plug Tesla.Middleware.Logger, debug: false - plug Tesla.Middleware.Headers, [{"User-Agent", "kdrive-bridge"}] - plug Tesla.Middleware.Headers, [{"Authorization", "Bearer #{Application.get_env(:kdrive_bridge, :kdrive_api_token)}"}] + plug Tesla.Middleware.Headers, [{"User-Agent", "ksuite-middleware"}] + plug Tesla.Middleware.Headers, [{"Authorization", "Bearer #{Application.get_env(:ksuite_middleware, :ksuite_api_token)}"}] plug Tesla.Middleware.Headers, [{"Content-Type", "application/json"}] plug Tesla.Middleware.FollowRedirects, max_redirects: 1 @spec download(integer()) :: {:error, any()} | {:ok, Tesla.Env.t()} def download(file_id) when is_integer(file_id) do - kdrive_id = Application.get_env(:kdrive_bridge, :kdrive_id) + kdrive_id = Application.get_env(:ksuite_middleware, :kdrive_id) get("/2/drive/#{kdrive_id}/files/#{file_id}/download") end @spec download_as(integer(), bitstring()) :: {:error, any()} | {:ok, Tesla.Env.t()} def download_as(file_id, as \\ "pdf") when is_integer(file_id) and is_bitstring(as) do - kdrive_id = Application.get_env(:kdrive_bridge, :kdrive_id) + kdrive_id = Application.get_env(:ksuite_middleware, :kdrive_id) get("/2/drive/#{kdrive_id}/files/#{file_id}/download", query: [as: as]) end end diff --git a/lib/kdrive_bridge_web.ex b/lib/ksuite_middleware_web.ex similarity index 80% rename from lib/kdrive_bridge_web.ex rename to lib/ksuite_middleware_web.ex index ad840af..3a1646b 100644 --- a/lib/kdrive_bridge_web.ex +++ b/lib/ksuite_middleware_web.ex @@ -1,12 +1,12 @@ -defmodule KdriveBridgeWeb do +defmodule KsuiteMiddlewareWeb do @moduledoc """ The entrypoint for defining your web interface, such as controllers, components, channels, and so on. This can be used in your application as: - use KdriveBridgeWeb, :controller - use KdriveBridgeWeb, :html + use KsuiteMiddlewareWeb, :controller + use KsuiteMiddlewareWeb, :html The definitions below will be executed for every controller, component, etc, so keep them short and clean, focused @@ -39,7 +39,7 @@ defmodule KdriveBridgeWeb do quote do use Phoenix.Controller, formats: [:html, :json], - layouts: [html: KdriveBridgeWeb.Layouts] + layouts: [html: KsuiteMiddlewareWeb.Layouts] import Plug.Conn @@ -50,9 +50,9 @@ defmodule KdriveBridgeWeb do def verified_routes do quote do use Phoenix.VerifiedRoutes, - endpoint: KdriveBridgeWeb.Endpoint, - router: KdriveBridgeWeb.Router, - statics: KdriveBridgeWeb.static_paths() + endpoint: KsuiteMiddlewareWeb.Endpoint, + router: KsuiteMiddlewareWeb.Router, + statics: KsuiteMiddlewareWeb.static_paths() end end diff --git a/lib/kdrive_bridge_web/controllers/error_json.ex b/lib/ksuite_middleware_web/controllers/error_json.ex similarity index 91% rename from lib/kdrive_bridge_web/controllers/error_json.ex rename to lib/ksuite_middleware_web/controllers/error_json.ex index ae415eb..718bb1e 100644 --- a/lib/kdrive_bridge_web/controllers/error_json.ex +++ b/lib/ksuite_middleware_web/controllers/error_json.ex @@ -1,4 +1,4 @@ -defmodule KdriveBridgeWeb.ErrorJSON do +defmodule KsuiteMiddlewareWeb.ErrorJSON do # If you want to customize a particular status code, # you may add your own clauses, such as: # diff --git a/lib/kdrive_bridge_web/controllers/main_controller.ex b/lib/ksuite_middleware_web/controllers/main_controller.ex similarity index 74% rename from lib/kdrive_bridge_web/controllers/main_controller.ex rename to lib/ksuite_middleware_web/controllers/main_controller.ex index f85d4c2..5ada3db 100644 --- a/lib/kdrive_bridge_web/controllers/main_controller.ex +++ b/lib/ksuite_middleware_web/controllers/main_controller.ex @@ -1,22 +1,22 @@ -defmodule KdriveBridgeWeb.MainController do - use KdriveBridgeWeb, :controller +defmodule KsuiteMiddlewareWeb.MainController do + use KsuiteMiddlewareWeb, :controller - alias KdriveBridge.KdriveClient + alias KsuiteMiddleware.KsuiteClient def index(conn, _params), do: conn |> put_resp_header("content-type", "text/html; charset=utf-8") - |> send_file(200, Application.app_dir(:kdrive_bridge, "priv/static/index.html")) + |> send_file(200, Application.app_dir(:ksuite_middleware, "priv/static/index.html")) def not_found(conn, _params), do: conn |> put_resp_header("content-type", "text/html; charset=utf-8") - |> send_file(404, Application.app_dir(:kdrive_bridge, "priv/static/not-found.html")) + |> send_file(404, Application.app_dir(:ksuite_middleware, "priv/static/not-found.html")) def pass_thru(conn, %{"file_id" => id}) when is_integer(id) do - with {:ok, response} <- KdriveClient.download(id) do + with {:ok, response} <- KsuiteClient.download(id) do conn |> put_tesla_response(response) else _ -> conn |> resp(500, "an unknown error occurred.") @@ -25,7 +25,7 @@ defmodule KdriveBridgeWeb.MainController do def pass_thru(conn, %{"file_id" => raw_id}) do with {file_id, _} <- Integer.parse(raw_id), - {:ok, response} <- KdriveClient.download(file_id) do + {:ok, response} <- KsuiteClient.download(file_id) do conn |> put_tesla_response(response) else _ -> @@ -40,7 +40,7 @@ defmodule KdriveBridgeWeb.MainController do do: conn |> put_resp_header("content-type", "text/html; charset=utf-8") - |> send_file(404, Application.app_dir(:kdrive_bridge, "priv/static/bad-api-key.html")) + |> send_file(404, Application.app_dir(:ksuite_middleware, "priv/static/bad-api-key.html")) defp put_tesla_response(%Plug.Conn{} = conn, %Tesla.Env{} = response) do %Tesla.Env{status: status, body: body} = response diff --git a/lib/kdrive_bridge_web/endpoint.ex b/lib/ksuite_middleware_web/endpoint.ex similarity index 83% rename from lib/kdrive_bridge_web/endpoint.ex rename to lib/ksuite_middleware_web/endpoint.ex index 3ec84ed..2c98f5c 100644 --- a/lib/kdrive_bridge_web/endpoint.ex +++ b/lib/ksuite_middleware_web/endpoint.ex @@ -1,12 +1,12 @@ -defmodule KdriveBridgeWeb.Endpoint do - use Phoenix.Endpoint, otp_app: :kdrive_bridge +defmodule KsuiteMiddlewareWeb.Endpoint do + use Phoenix.Endpoint, otp_app: :ksuite_middleware # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. # Set :encryption_salt if you would also like to encrypt it. @session_options [ store: :cookie, - key: "_kdrive_bridge_key", + key: "_ksuite_middleware_key", signing_salt: "xJIdm2OH", same_site: "Lax" ] @@ -19,9 +19,9 @@ defmodule KdriveBridgeWeb.Endpoint do # when deploying your static files in production. plug Plug.Static, at: "/", - from: :kdrive_bridge, + from: :ksuite_middleware, gzip: false, - only: KdriveBridgeWeb.static_paths() + only: KsuiteMiddlewareWeb.static_paths() # Code reloading can be explicitly enabled under the # :code_reloader configuration of your endpoint. @@ -44,5 +44,5 @@ defmodule KdriveBridgeWeb.Endpoint do plug Plug.MethodOverride plug Plug.Head plug Plug.Session, @session_options - plug KdriveBridgeWeb.Router + plug KsuiteMiddlewareWeb.Router end diff --git a/lib/kdrive_bridge_web/router.ex b/lib/ksuite_middleware_web/router.ex similarity index 73% rename from lib/kdrive_bridge_web/router.ex rename to lib/ksuite_middleware_web/router.ex index dea8460..1d6a455 100644 --- a/lib/kdrive_bridge_web/router.ex +++ b/lib/ksuite_middleware_web/router.ex @@ -1,5 +1,5 @@ -defmodule KdriveBridgeWeb.Router do - use KdriveBridgeWeb, :router +defmodule KsuiteMiddlewareWeb.Router do + use KsuiteMiddlewareWeb, :router pipeline :browser do plug :accepts, ["html"] @@ -10,20 +10,20 @@ defmodule KdriveBridgeWeb.Router do plug :accepts, ["json"] end - scope "/", KdriveBridgeWeb do + scope "/", KsuiteMiddlewareWeb do pipe_through :browser get "/", MainController, :index end - scope "/files", KdriveBridgeWeb do + scope "/files", KsuiteMiddlewareWeb do pipe_through :api get "/:file_id", MainController, :pass_thru end # Enable LiveDashboard in development - if Application.compile_env(:kdrive_bridge, :dev_routes) do + if Application.compile_env(:ksuite_middleware, :dev_routes) do # If you want to use the LiveDashboard in production, you should put # it behind authentication and allow only admins to access it. # If your application does not have an admins-only section yet, @@ -34,11 +34,11 @@ defmodule KdriveBridgeWeb.Router do scope "/dev" do pipe_through [:fetch_session, :protect_from_forgery] - live_dashboard "/dashboard", metrics: KdriveBridgeWeb.Telemetry + live_dashboard "/dashboard", metrics: KsuiteMiddlewareWeb.Telemetry end end - scope "/", KdriveBridgeWeb do + scope "/", KsuiteMiddlewareWeb do pipe_through :browser get "/*path", MainController, :not_found diff --git a/lib/kdrive_bridge_web/telemetry.ex b/lib/ksuite_middleware_web/telemetry.ex similarity index 95% rename from lib/kdrive_bridge_web/telemetry.ex rename to lib/ksuite_middleware_web/telemetry.ex index e6325af..c8b16d4 100644 --- a/lib/kdrive_bridge_web/telemetry.ex +++ b/lib/ksuite_middleware_web/telemetry.ex @@ -1,4 +1,4 @@ -defmodule KdriveBridgeWeb.Telemetry do +defmodule KsuiteMiddlewareWeb.Telemetry do use Supervisor import Telemetry.Metrics @@ -63,7 +63,7 @@ defmodule KdriveBridgeWeb.Telemetry do [ # A module, function and arguments to be invoked periodically. # This function must call :telemetry.execute/3 and a metric must be added above. - # {KdriveBridgeWeb, :count_users, []} + # {KsuiteMiddlewareWeb, :count_users, []} ] end end diff --git a/mix.exs b/mix.exs index 29f78e3..b749c71 100644 --- a/mix.exs +++ b/mix.exs @@ -1,10 +1,10 @@ -defmodule KdriveBridge.MixProject do +defmodule KsuiteMiddleware.MixProject do use Mix.Project def project do [ - app: :kdrive_bridge, - version: "0.3.0", + app: :ksuite_middleware, + version: "0.4.0", elixir: "~> 1.14", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, @@ -18,7 +18,7 @@ defmodule KdriveBridge.MixProject do # Type `mix help compile.app` for more information. def application do [ - mod: {KdriveBridge.Application, []}, + mod: {KsuiteMiddleware.Application, []}, extra_applications: [:logger, :runtime_tools] ] end diff --git a/mix.lock b/mix.lock index f284686..adc5113 100644 --- a/mix.lock +++ b/mix.lock @@ -1,10 +1,13 @@ %{ "castore": {:hex, :castore, "1.0.4", "ff4d0fb2e6411c0479b1d965a814ea6d00e51eb2f58697446e9c41a97d940b28", [:mix], [], "hexpm", "9418c1b8144e11656f0be99943db4caf04612e3eaecefb5dae9a2a87565584f8"}, "certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"}, + "combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm", "1b1dbc1790073076580d0d1d64e42eae2366583e7aecd455d1215b0d16f2451b"}, "cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, "cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"}, "dns_cluster": {:hex, :dns_cluster, "0.1.1", "73b4b2c3ec692f8a64276c43f8c929733a9ab9ac48c34e4c0b3d9d1b5cd69155", [:mix], [], "hexpm", "03a3f6ff16dcbb53e219b99c7af6aab29eb6b88acf80164b4bd76ac18dc890b3"}, + "expo": {:hex, :expo, "0.5.1", "249e826a897cac48f591deba863b26c16682b43711dd15ee86b92f25eafd96d9", [:mix], [], "hexpm", "68a4233b0658a3d12ee00d27d37d856b1ba48607e7ce20fd376958d0ba6ce92b"}, + "gettext": {:hex, :gettext, "0.24.0", "6f4d90ac5f3111673cbefc4ebee96fe5f37a114861ab8c7b7d5b30a1108ce6d8", [:mix], [{:expo, "~> 0.5.1", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "bdf75cdfcbe9e4622dd18e034b227d77dd17f0f133853a1c73b97b3d6c770e8b"}, "hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, @@ -23,11 +26,15 @@ "plug_crypto": {:hex, :plug_crypto, "2.0.0", "77515cc10af06645abbfb5e6ad7a3e9714f805ae118fa1a70205f80d2d70fe73", [:mix], [], "hexpm", "53695bae57cc4e54566d993eb01074e4d894b65a3766f1c43e2c61a1b0f45ea9"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, + "sweet_xml": {:hex, :sweet_xml, "0.7.4", "a8b7e1ce7ecd775c7e8a65d501bc2cd933bff3a9c41ab763f5105688ef485d08", [:mix], [], "hexpm", "e7c4b0bdbf460c928234951def54fe87edf1a170f6896675443279e2dbeba167"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, "telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"}, "telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"}, "tesla": {:hex, :tesla, "1.8.0", "d511a4f5c5e42538d97eef7c40ec4f3e44effdc5068206f42ed859e09e51d1fd", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.13", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, ">= 1.0.0", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.2", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:msgpax, "~> 2.3", [hex: :msgpax, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "10501f360cd926a309501287470372af1a6e1cbed0f43949203a4c13300bc79f"}, + "timex": {:hex, :timex, "3.7.11", "bb95cb4eb1d06e27346325de506bcc6c30f9c6dea40d1ebe390b262fad1862d1", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.20", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 1.1", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "8b9024f7efbabaf9bd7aa04f65cf8dcd7c9818ca5737677c7b76acbc6a94d1aa"}, + "tzdata": {:hex, :tzdata, "1.1.1", "20c8043476dfda8504952d00adac41c6eda23912278add38edc140ae0c5bcc46", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "a69cec8352eafcd2e198dea28a34113b60fdc6cb57eb5ad65c10292a6ba89787"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, "websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"}, "websock_adapter": {:hex, :websock_adapter, "0.5.5", "9dfeee8269b27e958a65b3e235b7e447769f66b5b5925385f5a569269164a210", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "4b977ba4a01918acbf77045ff88de7f6972c2a009213c515a445c48f224ffce9"}, + "xml_builder": {:hex, :xml_builder, "2.2.0", "cc5f1eeefcfcde6e90a9b77fb6c490a20bc1b856a7010ce6396f6da9719cbbab", [:mix], [], "hexpm", "9d66d52fb917565d358166a4314078d39ef04d552904de96f8e73f68f64a62c9"}, } diff --git a/priv/static/bad-api-key.html b/priv/static/bad-api-key.html index 000cb44..db870cd 100644 --- a/priv/static/bad-api-key.html +++ b/priv/static/bad-api-key.html @@ -39,10 +39,11 @@
-

KDrive - Bridge

+

Ksuite - Middleware

Ooopps!

-

It appears that the API key is incorrect. Please verify whether the environment variable KDRIVE_API_TOKEN has been properly defined.

+

It appears that the API key is incorrect. Please verify whether the environment variable KSUITE_API_TOKEN + has been properly defined.

diff --git a/priv/static/index.html b/priv/static/index.html index 4087387..cc720cd 100644 --- a/priv/static/index.html +++ b/priv/static/index.html @@ -3,7 +3,7 @@ - KDrive Bridge + Ksuite Middleware