Giter VIP home page Giter VIP logo

spray-akka-slick-postgres's Introduction

Build status for master branch Build Status

Spray-Akka-Slick-PostgreSQL CRUD app

This app can be used to manage Tasks in a todo list

  • It is a basic REST micro-service.
  • It abstracts CRUD operations on a database (in this case PostgreSQL)
  • It can be run standalone using a web browser and CURL
  • or it can receive web service calls from a web frontend. This is a good idea as it separates the web frontend from being able to directly access the database.

Application stack

  • Akka actors for lightweight, event-driven concurrent entities
  • Spray HTTPX higher-level logic for working with HTTP messages, which is not specific to the server-side (spray-routing)
  • Spray Routing DSL for defining RESTful web services
  • Play JSON de/serialization
  • Slick Functional Relational Mapping for Scala
  • PostgreSQL database
  • ScalaTest testing framework
  • Travis CI build server. The file .travis.yml contains the settings for the build server. Currently PostgreSQL 9.1, 9.2 and 9.3 are supported.

Development prerequisites

  1. JDK 1.7.51 or 1.8 must be installed

  2. Install SBT. The [current documentation][install-sbt] suggests:

    Mac:

    • Install Homebrew
    • Get the latest updates brew update
    • Install using brew brew install sbt
  3. Install PostgreSQL (source):

    Mac:

    • Install using brew brew install PostgreSQL
    • Create/Upgrade a database initdb /usr/local/var/postgres -E utf8
  4. Optional - Install Lunchy. Lunchy is a tool that allows you to easily start and stop the Postgres service, but you may prefer using a PostgreSQL command.

  5. Start the database service:

    Lunchy:

    • lunchy start postgres
  6. Create a PostgreSQL database for the user (see stackoverflow answer)

Configuration

The file application.conf specifies the values for:

  1. Micro-service:
    • port (currently 3000)
    • url (currently localhost)
  2. Database settings:
    • port (currently 5432)
    • database name
    • username
    • default password

Usage

The following examples assume the application.conf file is configures the app to run on localhost on port 3000:

  1. GET

    As a REST web service, you can perform any of the GET actions through a web browser or through CURL:

    • Count number of entries in Tasks table:

    http://localhost:3000/api/v1/tasks/count

    • List all tasks in the Tasks table:

    http://localhost:3000/api/v1/tasks/

  2. POST

    Sending data to the micro-service can be performed by using CURL to a POST route:

    • Create the task "Buy milk" with assignee "Me":

    curl -i -H "Content-Type:application/json" -d '{"content":"Buy milk", "assignee":"Me"}' http://localhost:3000/api/v1/tasks/

spray-akka-slick-postgres's People

Contributors

luc-at-jr avatar lucperkins avatar mericano1 avatar scottkwalker avatar

Watchers

 avatar  avatar

Forkers

scottkwalker

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.