| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Main goal of this project to show how you could use Finatra.
This example using Finatra for the backend and Slick for work with H2 that used as data storage. AngularJS + Bootstrap for the frontend as Single Page Application.
Finatra requires either maven or sbt to build and run your app.
You can get this example through Activator. For more information please use following url that explains how to get this template on your computer step-by-step: https://typesafe.com/activator/template/finatra-angular-example
For managing dependencies for the frontend application using Bower.
Before running application please install frontend dependencies by using following command:
$ bower install
Ti run application use following command:
$ sbt run
It will start on port 7070, so you should see result on: http://localhost:7070
You can run tests:
$ sbt test
Application contain public API and private that requires authentication first.
You can use cURL to test application.
API response in JSON format.
Supported request types:
If you will asked for another type, server will response with code 406 and message No matching accepted Response format could be determined!.
You can configure version of your API at resources/application.conf.
Make sure that your requests contain correct version of API.
Default version is set to 3.
You can get authentication token for your communication with server's private API by querying following URL:
$ curl -i -H Accept:application/json -X POST http://localhost:7070/api/v3/users/authentication
You will get response status 201 - because this method will fake user creation and provide you with auth token for private API.
You can also can check list of authenticated users by following URL (this part made only for debugging, limit is optional parameter, default 10. If limit < 0 then you will get all data):
$ curl -i -H Accept:application/json -X GET -G http://localhost:7070/api/v3/users -d limit={limit.?}
You should get response code 200.
On following URL you can get list of available products (limit is optional parameter, default 10. If limit < 0 then you will get all data):
curl -i -H Accept:application/json -X GET -G http://localhost:7070/api/v3/products -d limit={limit.?}
You should get response code 200.
For this part of API you need to have authentication toking provided by /api/v3/users/authentication. You should pass token in header with key token.
You can get list of all products currently in your basket:
$ curl -i -H Accept:application/json -X GET -G http://localhost:7070/api/v3/cart/products -H token:{token}
Add new product to your basket:
$ curl -i -H Accept:application/json -X PUT http://localhost:7070/api/v3/cart/products/{productId} -H token:{token}
You can update quantity of product that is already in your basket:
$ curl -i -H Accept:application/json -X PUT http://localhost:7070/api/v3/cart/products/{productId}/quantity/{quantity} -H token:{token}
You can remove product from your cart using following URL:
$ curl -i -H Accept:application/json -X DELETE -G http://localhost:7070/api/v3/cart/products/{productId} -H token:{token}
Copyright (C) 2014 Pavlo Voznenko.
Distributed under the MIT License.
| Back | FazBrowse Home | New Git URL |