Coder Social home page Coder Social logo

globomantics-cf-backend's Introduction

globomantics-cf-backend

Contains codebase for different modules from Pluralsight course - Scala Specific Design Patterns

The course is divided in modules, hence for each, code is kept in directory called module_x. E.g. module_3

To run project specific to a particular module:

  • Go to respective directory cd modules/module_3
  • Give sbt run to run the service

Above command should run the service at localhost:8080. You may use any REST Client e.g. POSTMAN to test the service endpoints.

E.g. To create a new User, you may send a POST request to http://localhost:8080/api/v1/users with below request JSON (Content-type: application/json).

{
	"id": "323c78ec-1eb8-4410-b284-f75079b15708",
	"name": "Alex Bar",
	"email": "[email protected]",
	"password": "plain_pwd",
	"address": {
		"addressLine": "04-444, Block 444",
		"location": {
			"pin": "302012",
			"city": "Jaipur",
			"country": "India"
		}
	},
	"role": "Speaker"
}

Above request should give you a success response, if everything is ok.

Note: The project (module_4 onwards) uses Docker for running postgres database. So to follow along, ensure Docker is installed on your machine and running.

Once Docker is running:

  • Create a directory for docker volume e.g. On Mac/Linux: mkdir -p $HOME/docker/volumes/postgres
  • Run the postgres image docker run --rm --name pg-docker -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres
  • Ensure if it's running: docker ps The command should show something like: 7bc71fbb33e0 postgres "docker-entrypoint.s…" 14 minutes ago Up 14 minutes 0.0.0.0:5432->5432/tcp pg-docker

Configure postgres by following below steps:

  • Enter inside interactive bash shell on the container to use postgres docker exec -it pg-docker /bin/bash
  • Open psql for localhost psql -h localhost -U postgres -d postgres Above command says Open psql server running on localhost under user postgres and connect to database named postgres
  • Create a database, a user, and provide permissions on database to the user created.
CREATE DATABASE "pgconfedb" WITH ENCODING 'UTF8';
CREATE USER "trustworthy" WITH PASSWORD 'trust';
GRANT ALL ON DATABASE "pgconfedb" TO trustworthy;

This should set postgres with desired configuration. Above configuration(i.e. databaseName, user and password) is required in project's resources/application.conf file:

conferencedb = {
  connectionPool = "HikariCP"
  dataSourceClass = "org.postgresql.ds.PGSimpleDataSource"
  properties = {
	  serverName = "localhost"
	  portNumber = "5432"
	  databaseName = "pgconfedb"
	  user = "trustworthy"
	  password = "trust"
	  url = "jdbc:postgresql://localhost:5432/pgconfedb"
  }
  numThreads = 10
}

Note: Module 6 uses API Key to access google maps API, you may change the configuration. For obvious reasons, this key will no longer work.

//This key will no longer work
maps {
  apiKey = "OIUYyBLPJHT-e4Mze9li216YDsmedpKrdIlIiU"
}

globomantics-cf-backend's People

Contributors

vi-kas avatar

Stargazers

Waqar Yunus Shaikh avatar  avatar

Watchers

James Cloos avatar  avatar Gustavo Muniz avatar

globomantics-cf-backend's Issues

Project Setup

On following project setup instructions;

➜globomantics-cf-backend/modules/module_3(master)» sbt run                                                                                                     [17:45:03]
[info] Loading global plugins from /Users/imransarwar/.sbt/1.0/plugins
[info] Loading project definition from /Users/imransarwar/git/globomantics-cf-backend/modules/module_3/project
[info] Updating ProjectRef(uri("file:/Users/imransarwar/git/globomantics-cf-backend/modules/module_3/project/"), "module_3-build")...
[info] Done updating.
error: error while loading String, class file '/modules/java.base/java/lang/String.class' is broken
(class java.lang.NullPointerException/null)
[error] java.io.IOError: java.lang.RuntimeException: /packages cannot be represented as URI
[error] 	at java.base/jdk.internal.jrtfs.JrtPath.toUri(JrtPath.java:176)
[error] 	at scala.tools.nsc.classpath.JrtClassPath.asURLs(DirectoryClassPath.scala:204)
[error] 	at scala.tools.nsc.classpath.AggregateClassPath.$anonfun$asURLs$1(AggregateClassPath.scala:55)
[error] 	at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:240)
[error] 	at scala.collection.Iterator.foreach(Iterator.scala:937)

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.