Skip to content

doriancodes/finch-simple-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Finch-simple-app

This is an app to get started using Finch. This app has been configured to run on Heroku: check https://finch-simple-app.herokuapp.com/hello .

Set up

Make sure you have Postgres installed and then run the following scripts to fill the database:

$ curl -O https://raw.githubusercontent.com/tpolecat/doobie/series/0.5.x/world.sql
$ psql -c 'create user postgres createdb'
$ psql -c 'create database world;' -U postgres
$ psql -c '\i world.sql' -d world -U postgres
$ psql -c 'create database worldtest;' -U postgres
$ psql -c '\i world.sql' -d worldtest -U postgres

This dataset and sample data has been taken from the book of doobie: https://tpolecat.github.io/doobie/docs/01-Introduction.html

Usage

To run the app locally, type on the command line:

sbt run

To run the tests:

sbt test

For the moment it has these endpoints:

/hello

Example request:

curl  --request GET http://localhost:8081/hello

Example response

{"message":"Hello, world!"}

/time

Example request:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"language":"de","country":"DE"}' \
  http://localhost:8081/time

Example response:

{"locale":{"language":"de","country":"DE"},"time":"Fri Mar 29 17:04:34 CET 2019"}

/countries

Example request:

curl  --request GET http://localhost:8081/countries

Example response (very long list):

[{"code":"AFG","name":"Afghanistan","pop":22720000,"gnp":5976.00},{"code":"NLD","name":"Netherlands","pop":15864000,"gnp":371362.00},{"code":"ANT","name":"Netherlands Antilles","pop":217000,"gnp":1941.00}, ...]

About

Basic finch app template to get started

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages