{"id":18466318,"url":"https://github.com/ritreshgirdhar/elixir-phoenix-rest-api","last_synced_at":"2025-07-27T12:35:57.175Z","repository":{"id":78314170,"uuid":"374672685","full_name":"RitreshGirdhar/elixir-phoenix-rest-api","owner":"RitreshGirdhar","description":"Elixir Rest Api application example","archived":false,"fork":false,"pushed_at":"2021-06-07T14:00:45.000Z","size":1059,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-04T08:54:47.424Z","etag":null,"topics":["ecto","elixir","elixir-examples","elixir-phoenix","elixir-programming-language"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RitreshGirdhar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-07T13:18:10.000Z","updated_at":"2021-06-07T14:01:51.000Z","dependencies_parsed_at":"2023-06-15T23:45:46.847Z","dependency_job_id":null,"html_url":"https://github.com/RitreshGirdhar/elixir-phoenix-rest-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RitreshGirdhar%2Felixir-phoenix-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RitreshGirdhar%2Felixir-phoenix-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RitreshGirdhar%2Felixir-phoenix-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RitreshGirdhar%2Felixir-phoenix-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RitreshGirdhar","download_url":"https://codeload.github.com/RitreshGirdhar/elixir-phoenix-rest-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252310962,"owners_count":21727516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecto","elixir","elixir-examples","elixir-phoenix","elixir-programming-language"],"created_at":"2024-11-06T09:16:02.163Z","updated_at":"2025-05-04T08:54:51.192Z","avatar_url":"https://github.com/RitreshGirdhar.png","language":"Elixir","readme":"# elixir-phoenix-rest-api\n\n\nhttps://www.dairon.org/2020/07/06/simple-rest-api-with-elixir-phoenix.html\n\nSteps \n\n1.\n``` \n    $ mix phx.new books_api --no-html --no-webpack --binary-id \u0026\u0026 cd books_api\n    * creating books_api/config/config.exs\n* creating books_api/config/dev.exs\n* creating books_api/config/prod.exs\n* creating books_api/config/prod.secret.exs\n* creating books_api/config/test.exs\n* creating books_api/lib/books_api/application.ex\n* creating books_api/lib/books_api.ex\n* creating books_api/lib/books_api_web/channels/user_socket.ex\n* creating books_api/lib/books_api_web/views/error_helpers.ex\n* creating books_api/lib/books_api_web/views/error_view.ex\n* creating books_api/lib/books_api_web/endpoint.ex\n* creating books_api/lib/books_api_web/router.ex\n* creating books_api/lib/books_api_web/telemetry.ex\n* creating books_api/lib/books_api_web.ex\n* creating books_api/mix.exs\n* creating books_api/README.md\n* creating books_api/.formatter.exs\n* creating books_api/.gitignore\n* creating books_api/test/support/channel_case.ex\n* creating books_api/test/support/conn_case.ex\n* creating books_api/test/test_helper.exs\n* creating books_api/test/books_api_web/views/error_view_test.exs\n* creating books_api/lib/books_api/repo.ex\n* creating books_api/priv/repo/migrations/.formatter.exs\n* creating books_api/priv/repo/seeds.exs\n* creating books_api/test/support/data_case.ex\n* creating books_api/lib/books_api_web/gettext.ex\n* creating books_api/priv/gettext/en/LC_MESSAGES/errors.po\n* creating books_api/priv/gettext/errors.pot\n\nFetch and install dependencies? [Yn] Y\n* running mix deps.get\n* running mix deps.compile\n\nWe are almost there! The following steps are missing:\n\n    $ cd books_api\n\nThen configure your database in config/dev.exs and run:\n\n    $ mix ecto.create\n\nStart your Phoenix app with:\n\n    $ mix phx.server\n\nYou can also run your app inside IEx (Interactive Elixir) as:\n\n    $ iex -S mix phx.server\n\n```\n\n``` \n$ cd books_api/\n\n$ mix ecto.create\nCompiling 11 files (.ex)\nGenerated books_api app\nThe database for BooksApi.Repo has already been created\n```\n\n``` \n$ mix phx.server\n[info] Running BooksApiWeb.Endpoint with cowboy 2.9.0 at 0.0.0.0:4000 (http)\n[info] Access BooksApiWeb.Endpoint at http://localhost:4000\n```\n\nDB changes \n``` \n\n\n```\n\n```\nconnect to db Image pacto\n\n\n```\n\n``` \ndrop schema\n\n$ mix ecto.drop   \n** (Mix) The database for BooksApi.Repo couldn't be dropped: ERROR 55006 (object_in_use) database \"books_api_dev\" is being accessed by other users\nThere is 1 other session using the database.\n```\n\nClose postico connection\n``` \n$ mix ecto.drop\nThe database for BooksApi.Repo has been dropped\n```\n\n``` \n$ mix ecto.create\nThe database for BooksApi.Repo has been created\n```\n\n``` \nmix phx.gen.context Store Book books \\\n\u003e title:string isbn:text:unique description:text price:float authors:array:string\n* creating lib/books_api/store/book.ex\n* creating priv/repo/migrations/20210607133628_create_books.exs\n* creating lib/books_api/store.ex\n* injecting lib/books_api/store.ex\n* creating test/books_api/store_test.exs\n* injecting test/books_api/store_test.exs\n\nRemember to update your repository by running migrations:\n\n    $ mix ecto.migrate\n\n```\n\n\n``` \n$ mix ecto.migrate\nCompiling 2 files (.ex)\nGenerated books_api app\n\n19:08:46.734 [info]  == Running 20210607133628 BooksApi.Repo.Migrations.CreateBooks.change/0 forward\n\n19:08:46.739 [info]  create table books\n\n19:08:46.749 [info]  create index books_isbn_index\n\n19:08:46.755 [info]  == Migrated 20210607133628 in 0.0s\n\n```\n\nTODO \u003e\u003eimage3\n\n\n``` \n$ mix phx.gen.json Store Book books \\\n\u003e title:string isbn:text:unique description:text price:float authors:array:string --no-context --no-schema\nYou are generating into an existing context.\n\nThe BooksApi.Store context currently has 6 functions and 1 files in its directory.\n\n  * It's OK to have multiple resources in the same context as long as they are closely related. But if a context grows too large, consider breaking it apart\n\n  * If they are not closely related, another context probably works better\n\nThe fact two entities are related in the database does not mean they belong to the same context.\n\nIf you are not sure, prefer creating a new context over adding to the existing one.\n\nWould you like to proceed? [Yn] Y\n* creating lib/books_api_web/controllers/book_controller.ex\n* creating lib/books_api_web/views/book_view.ex\n* creating test/books_api_web/controllers/book_controller_test.exs\n* creating lib/books_api_web/views/changeset_view.ex\n* creating lib/books_api_web/controllers/fallback_controller.ex\n\nAdd the resource to your :api scope in lib/books_api_web/router.ex:\n\n    resources \"/books\", BookController, except: [:new, :edit]\n\n```\n\nchange router.ex\n``` \n  scope \"/api\", BooksApiWeb do\n    pipe_through :api\n    resources \"/books\", BookController, except: [:new, :edit]\n  end\n```\n\n``` \n$ mix phx.server\nCompiling 5 files (.ex)\nGenerated books_api app\n[info] Running BooksApiWeb.Endpoint with cowboy 2.9.0 at 0.0.0.0:4000 (http)\n[info] Access BooksApiWeb.Endpoint at http://localhost:4000\n\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fritreshgirdhar%2Felixir-phoenix-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fritreshgirdhar%2Felixir-phoenix-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fritreshgirdhar%2Felixir-phoenix-rest-api/lists"}