Skip to content

My first project in Elixir using the Phoenix framework - a simple API connected to a dockerized postgres server.

Notifications You must be signed in to change notification settings

infomanc3r/Elixir-First-Phoenix-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

First API using Elixir + Phoenix

Purpose

This demo was created so that I could learn the Phoenix framework and practice writing Elixir to set up an API with a dockerized Postgres integration. The API could be adapted for other purposes and may provide you with a useful starting point.

Prerequisites

docker pull postgres

docker run --name EXAMPLE_NAME -p 5432:5432 -e POSTGRES_USER=EXAMPLE_USER -e POSTGRES_PASSWORD=EXAMPLE_PASS -d postgres

It is important that you set a custom username and password! Malicious actors scan for Postgres servers with the default username and password and cryptojack them. Not a problem if you're staying on localhost, but important to keep in mind if you're deploying to a server.

Setup

  • In the config folder, find the dev.exs file and change the username, password, and database name to match your Postgres server.
  • Run mix setup to install and setup dependencies
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

The default port is 4000 and you may access the API using localhost:4000 from your browser. Routing is listed in router.ex and the .ex files in the 'controllers' folder.

About

My first project in Elixir using the Phoenix framework - a simple API connected to a dockerized postgres server.

Topics

Resources

Stars

Watchers

Forks