Skip to content

paulporu/Play-User-Queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Play-User-Queue

Build Status

This REST API allows for flexible management of users in waiting queues. It was built on top of Play Scala and MongoDB, and illustrates how this custom Priority Queue implementation can be used in Scala projects.

Setup

  1. Install MongoDB.
  2. Download Typesafe Activator
  3. Extract the zip and run the activator script from a non-interactive shell
  4. Your browser should open to the Activator UI: http://localhost:8888

Run the App

Using the Activator UI you can compile the code, run tests, and run the app. You can see the running application at: http://localhost:9000/

You can also use the command line:

$ activator ~run
$ activator ~test

For more information you can visit: https://www.playframework.com/documentation/2.5.x/PlayConsole

Endpoints

Users

GET /user/get Gets user details
POST /user/delete Deletes user from DB
POST /user/add Adds new user to DB
POST /user/update Updates user

Queues

GET /queue/all Gets queue details POST /queue/add Adds new queue to DB
POST /queue/delete Deletes queue from DB
POST /queue/cleanup Removes deleted users from queue
GET /queue/getFirst Gets first user in queue
GET /queue/getAll Gets all users in queue
POST /queue/popFirst Pops first user from queue
POST /queue/enqueue Adds user to queue
POST /queue/dequeue Removes user from queue
POST /queue/bump Moves user to the top of the queue

Dependencies

The ReactiveMongo plugin for Play was used as the Scala driver for MongoDB.
The ScalaTest + Play integration library was used for testing the Play application with Scalatest.
Scalastyle was used because it's always good to follow some guidelines.

Stylistic Note:

In this application, pattern matching was usually chosen over map.getOrElse or fold for readability purposes. As a personal preference I often use the first two interchangeably but fold does seem to produce less readable code in most cases. Also see: https://www.reddit.com/r/scala/comments/449td4/fold_or_pattern_matching_with_an_option/

License

MIT License

About

A Play Scala REST API for flexible management of users in waiting queues.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages