Application to demonstrate various parts of a service oriented RESTfull application.
| Component | Technology |
|---|---|
| Frontend | Angular 2 |
| Backend (REST) | SpringBoot (Java) |
| Security | Token Based (Spring Security and JWT ) |
| REST Documentation | Swagger UI / Springfox and ReDoc |
| REST Spec | Open API Standard |
| In Memory DB | H2 |
| Persistence | JPA (Using Spring Data) |
| Client Build Tools | angular-cli, Webpack, npm |
| Server Build Tools | Maven(Java) or Gradle |
PROJECT_FOLDER
│ README.md
│ pom.xml
│
└──[src]
│ └──[main]
│ └──[java]
│ └──[resources]
│ │ application.properties #contains springboot cofigurations
│ │ schema.sql # Contains DB Script to create tables that executes during the App Startup
│ │ data.sql # Contains DB Script to Insert data that executes during the App Startup (after schema.sql)
│ └──[public] # keep all html,css etc, resources that needs to be exposed to user without security
│
└──[target] #Java build files, auto-created after running java build: mvn install
│ └──[classes]
│ └──[public]
│ └──[webui] #webui folder is created by (maven/gradle) which copies webui/dist folder
│ #the application.properties file list webui as a resource folder that means files can be accesses http://localhost/<files_inside_webui>
│
└──[webui]
│ package.json
│ angular-cli.json #ng build configurations)
└──[node_modules]
└──[src] #frontend source files
└──[dist] #frontend build files, auto-created after running angular build: ng -buildEnsure you have this installed before proceeding further
- Java 8
- Maven 3.3.9 or Gradle 3.3
- Node 7.2.1,
- npm 3.9.5,
- Angular-cli
- Clone the repo in a folder
- You must follow the installation sequence
- First Install Frontend
- Then Install Backend
# Navigate to PROJECT_FOLDER/webui (should cntain package.json )
npm install
# build the project (this will put the files under dist folder)
ng build -prod --aot=falseto enable Spring Token security the setting
# Maven Build : Navigate to the root folder where pom.xml is present
mvn clean install
#OR
# Gradle Build : Navigate to the root folder where build.gradle is present
gradle build
# Start the server (9119)
# port and other configurations for API servere is in [./cofig/application.properties](https://github.com/mrin9/Angular2_SpringBoot/blob/master/config/application.properties) file
# If you build with maven jar location will be
java -jar ./target/app-1.0.0.jar
# If you build with gradle jar location will be
java -jar ./build/libs/app-1.0.0.jar| Cpmponent | URL | Credentials |
|---|---|---|
| Frontend | http://localhost:9119 | demo/demo |
| H2 Database | http://localhost:9119/h2-console | Driver:org.h2.Driver, JDBC URL:jdbc:h2:mem:demo, User Name:sa |
| Swagger (API Ref) | http://localhost:9119/swagger-ui.html | |
| Redoc (API Ref) | http://localhost:9119/redoc/index.html |
To get an authentication token
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"username": "demo", "password": "demo" }' 'http://localhost:9119/session'or POST the username and password to http://localhost:9119/session
after you get the authentication token you must provide this in the header for all the protected urls
curl -X GET --header 'Accept: application/json' --header 'Authorization: [replace this with token ]' 'http://localhost:9119/version'