Skip to content

anilsenay/scala-slick-rest-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scala-slick-rest-postgresql

First Scala REST Api attempt for learning in a week. I used Akka-Http, Scala Slick as FRM for database connection and PostgreSQL with Docker.

Build With

Getting Started

Prerequisites

Installation

  1. Clone the repo and change the directory
git clone https://github.com/anilsenay/scala-slick-rest-postgresql.git
cd scala-slick-rest-postgresql
  1. Run Docker Compose to setup and run PostgreSQL in a Docker container
docker compose up
  1. When your docker is running and PostgreSQL is ready, compile and run the project
sbt run

Configuration

Change database credentials

Change credentials in both docker-compose.yml and src/main/resources/application.conf files

Change secret key for generating JWT

Change secretKey in src/main/resources/application.conf file

API REST Interface

Download Postman Collection: GDrive

You have to be authorized for access some endpoints by adding user's JWT token as Bearer to Authorization key in request header.

AUTH

  • POST /api/auth/login
  • POST /api/auth/register
  • POST /api/auth/validate

USER

  • GET /api/user
  • GET /api/user/{user_id}
  • GET /api/user/{user_id}?address=true
  • POST /api/user
  • PUT /api/user/{user_id}
  • DELETE /api/user/{user_id}
  • POST /api/user/{user_id}/address

ADDRESS

  • GET /api/address
  • GET /api/address/{address_id}
  • POST /api/address
  • PUT /api/address/{address_id}
  • DELETE /api/address/{address_id}

PRODUCT

  • GET /api/product
  • GET /api/product/{product_id}
  • GET /api/product?sort=asc&category=Shoes&min=1000&max=1000&brand=adidas&sort=new&page=2
  • POST /api/product
  • POST /api/product/{product_id}/photo
  • POST /api/product/{product_id}/size
  • PUT /api/product/{product_id}
  • DELETE /api/product/{product_id}
  • DELETE /api/product/product_id/photo/{photo_index}
  • DELETE /api/product/product_id/size/{size}

CATEGORY

  • GET /api/category
  • POST /api/category
  • PUT /api/category/{category_id}
  • DELETE /api/category/{category_id}

BRAND

  • GET /api/brand
  • POST /api/brand
  • PUT /api/brand/{brand_id}
  • DELETE /api/brand/{brand_id}

ORDER

  • GET /api/order/{order_id}
  • GET /api/order/{order_id}?user={user_id}
  • POST /api/order
  • PUT /api/order/{order_id}/{status}
  • PUT /api/order/{order_id}/cancel
  • DELETE /api/order/{order_id}

Future plans

  • Applying best practices
  • Implement Swagger
  • Implement authentication
  • Implement a cache mechanism
  • Better Error messages
  • Create same project by using Akka Play framework & use Quill instead of Slick

License

Distributed under the GPL License. See LICENSE for more information.

Contact

@anilsenay

Project Link: https://github.com/anilsenay/scala-slick-rest-postgresql