Skip to content

Commit

Permalink
Modified README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Naterus committed Oct 19, 2020
1 parent 6b33442 commit 9ac2b8a
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 67 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Play Hello World Web Tutorial for Java
# Backend REST API service implementation in Java to manage Cars and Drivers

To follow the steps in this tutorial, you will need the correct version of Java and a build tool. You can build Play projects with any Java build tool. Since sbt takes advantage of Play features such as auto-reload, the tutorial describes how to build the project with sbt.
To run the car and drivers restful service, you will need the correct version of Java and a build tool. You can build Play projects with any Java build tool. Since sbt takes advantage of Play features such as auto-reload.

Prerequisites include:

* Java Software Developer's Kit (SE) 1.8 or higher
* sbt 0.13.15 or higher (we recommend 1.2.3) Note: if you downloaded this project as a zip file from https://developer.lightbend.com, the file includes an sbt distribution for your convenience.
* sbt 1.2.0 or higher (I recommend 1.3.4) the file includes an sbt distribution for your convenience.

To check your Java version, enter the following in a command window:

Expand All @@ -20,16 +20,76 @@ If you do not have the required versions, follow these links to obtain them:
* [Java SE](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
* [sbt](http://www.scala-sbt.org/download.html)

## Build and run the project

This example Play project was created from a seed template. It includes all Play components and an Akka HTTP server. The project is also configured with filters for Cross-Site Request Forgery (CSRF) protection and security headers.
## Run the project

To build and run the project:

1. Use a command window to change into the example project directory, for example: `cd play-java-hello-world-web`
1. Use a command window to change into the example project directory, for example: `cd car-driver-service`

2. Build the project. Enter: `sbt run`. The project builds and starts the embedded HTTP server. Since this downloads libraries and dependencies, the amount of time required depends partly on your connection's speed.

3. After the message `Server started, ...` displays, enter the following URL in a browser: <http://localhost:9000>

The Play application responds: `Welcome to the Hello World Tutorial!`

## Access Api endpoints
1. Generate authorization token from the endpoint: <http://localhost:9000/api/v1/authorization/generate-key> - attach a raw json object to the request e.g `{
"name" : "John Doe",
"email" : "[email protected]"
}`. the response should contain the authorization token. ensure you copy it.

2. Attach the generated token as a header parameter with the key : authorization and value : <your-token> across all request (Preferably use postman to test).

## Test with swagger
1. Swagger interface is integrated in the project. once the project runs successfully, you can access swagger-ui from the URL : <http://localhost:9000/docs/swagger-ui/index.html?url=/assets/swagger.json#/>

2. You can get the list of endpoints in swagger Ui also.

## Example data
1. To create driver , add raw json object to the request e.g `{
"username" : "doe111",
"password" : "12345",
"age" : 45,
"firstName" : "John",
"lastName" : "Doe",
"onlineStatus" : "Online",
"contactNumber" : "0815558555u",
"gender" : "Male"
}`

2. To create car, add raw json object to the request e.g `{
"licencePlate": "Jyc-eee",
"convertible": "Yes",
"rating": 5,
"engineType": "Electric",
"colour": "Blue",
"model": "2020",
"manufacturer": "Innoson",
"speedLimit": "360km/h"
}`

3. To select/deselect car, add raw json object to their endpoints e.g ` {
"carId" : 1,
"driverId" : 2
}`

4. To update both car, add json payload to request e.g ` "licencePlate": "Jyc-eee",
"convertible": "Yes",
"rating": 5,
"engineType": "Electric",
"colour": "Blue",
"model": "2020",
"manufacturer": "Innoson",
"speedLimit": "360km/h"
}`

5. To update driver, add raw json object to the request e.g `{
"username" : "doe111",
"password" : "12345",
"age" : 45,
"firstName" : "John",
"lastName" : "Doe",
"onlineStatus" : "Online",
"contactNumber" : "0815558555u",
"gender" : "Male"
}`
Binary file modified data/carServiceDB.mv.db
Binary file not shown.

0 comments on commit 9ac2b8a

Please sign in to comment.