Skip to content

Movie library service written in a functional way using Typelevel stack.

License

Notifications You must be signed in to change notification settings

bszwej/functional-movie-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Functional Movie Library

This repository contains a movie library service written in a functional way.

Overview

Things you can find here:

  • http4s
  • circe
  • cats and cats-effect
  • pureconfig
  • refined
  • practical usage of EitherT
  • tagless final
  • scanamo with custom interpreter for Async from cats-effect (purely for fun & learning)
  • ...

This experiment is a side-effect of playing around with Typelevel libraries. It was inspired by:

Running

  1. Download local DynamoDB here.
  2. Run local DynamoDB:
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
  1. Go to DynamoDB local shell http://localhost:8000/shell and create a table:
const params = {
    TableName: 'movies',
    KeySchema: [
        {
            AttributeName: 'id',
            KeyType: 'HASH'
        }
    ],
    AttributeDefinitions: [
        {
            AttributeName: 'id',
            AttributeType: 'N'
        }
    ],
    ProvisionedThroughput: {
        ReadCapacityUnits: 5,
        WriteCapacityUnits: 5
    }
};

dynamodb.createTable(params, function(err, data) {
    if (err) ppJson(err);
    else ppJson(data);
});
  1. Run the service sbt run
  2. Make some calls:
curl http://localhost:8080/movies -d '{"title": "Star Wars IV", "year": 1977, "id": 1}'
curl http://localhost:8080/movies -d '{"title": "pulp fiction", "year": 1994, "id": 2}'
curl http://localhost:8080/movies
curl http://localhost:8080/movies/1
curl -X DELETE http://localhost:8080/movies/1
curl http://localhost:8080/movies

Testing

sbt test

Releases

No releases published

Packages

No packages published

Languages