Giter Site home page Giter Site logo

librity / ignite_nutri_tests Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 29 KB

Rocket Seat - Ignite - Elixir - Challenge 9 - A tested calories counter backend made with Phoenix.

Elixir 100.00%
rocketseat-ignite elixir phoenix-framework challenge calories-counter

ignite_nutri_tests's Introduction

Rocket Seat Ignite - Nutri

Table of Contents

About

A calories counter backend made with Phoenix.

Endpoints

Built-in:

Meals

Setup

Install Erlang, Elixir and Phoenix.

Postgres

Create a postgress docker container with:

$ docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres

Bash Commands

# Create phoenix app without webpacker or html views
$ mix phx.new app_name --no-webpack --no-html

# Intall dependencies
$ mix deps.get

# Compile project
$ mix compile

# Generate linter config file
$ mix credo.gen.config

# Run linter
$ mix credo --strict

# Start Phoenix dev server on http://localhost:4000
$ mix phx.server

# Start your project as an Interactive Elixir session
$ iex -S mix

# List all configured routes
$ mix phx.routes

Ecto:

# Create and migrate database
$ mix ecto.setup

# Create a migration
$ mix ecto.gen.migration create_users_table

# Run pending migrations
$ mix ecto.migrate

# Drop and migrate databases
$ mix ecto.reset

# Drop databases
$ mix ecto.drop

# Create databases
$ mix ecto.create

Tests

# Run tests
$ mix test

# Run tests w/ coverage report
$ mix test --cover

Elixir Commands

Create a meal:

> meal_params = %{
  description: "Royal with cheese",
  date: "1994-05-21 12:00:00",
  calories: 500
}
> Nutri.Meals.Create.call(meal_params)

Fetch meals:

> Nutri.Repo.all(Nutri.Meal)
> Nutri.Repo.get(Nutri.Meal, 1)

> Nutri.get_meals()
> Nutri.get_meal_by_id(1)

Update meal:

> new_meal_params = %{
  "id" => 1,
  "description" => "UPDATEDDDDDDD",
  "date" => "2021-03-24 12:00:00",
  "calories" => 1000
}
> Nutri.Meals.Update.call(new_meal_params)

Delete meal:

> Nutri.delete_meal(1)

Libs

Docs

Resources

ignite_nutri_tests's People

Contributors

librity avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.