Git Product home page Git Product logo

appone's Introduction

APPONE - BOOKSWAP

BOOKSWAP LOGO

About Me

At the time of building this, I am a Junior Scala Developer. About half a year ago I started a new job where the company programmes in Scala with a functional tech stack.

The idea of this app is simple and follow CRUD format:

  1. POST a book
  2. GET a book
  3. PUT (update) a book
  4. DELETE a book

The core purpose of app one is for me to understand how to deploy a very simple app.

For this app I deployed using Heroku, I chose to use this platform as I thought it would be an easy place to start. In the future, I will try to deploy to AWS in dockerised containers.

Learning outcomes

  • Build a simple backend Scala app
  • connect a database
  • write a few tests
  • deploy to Herko
  • Add CI/CD

Tech Stack

  • Scala
  • Cats
  • Cats Effect
  • Doobie
  • Docker-compose
  • Circe
  • Heroku

What I learnt

I wasn't too familar on how to properly use environment variables and application.conf files.

My original plan was to have an application.conf file and have a meta directory. The meta directory would have two files: dev.env and prd.env. I would have something which ran source meta/prd.env when in production (heroku).

Unfortunately this cannot be achieved as I could not store variables statically in that location/file as Heroku updates its variables every so often, meaning the variables within prd.env would become out of date.

Addtionally my original plan would be against the https://www.12factor.net/ coding principles.

 def prodConfig(): Config = {
    val dbUri = new URI(System.getenv("DATABASE_URL"))
    val username = dbUri.getUserInfo.split(":")(0)
    val password = dbUri.getUserInfo.split(":")(1)
    val dbUrl = "jdbc:postgresql://" + dbUri.getHost + dbUri.getPath

    Config(ServerConfig(5432, dbUri.getHost), DbConfig(dbUrl, username, password, 10))
  }

Instead of using LoadConfig I used the above function to capture and chop the DATABASE_URL which is injected by Heroku, I then pass that to the various parts of config that need it.

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.