Skip to content

{frontEnd: Angular2, backEnd: java-SpringBoot, security: TokenBased JWT, liveRESTDoc: swagger-openAPI}

Notifications You must be signed in to change notification settings

tuonglx/Angular2_SpringBoot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Angular 2 Frontent with SpringBoot (Java) Backend

Application to demonstrate various parts of a service oriented RESTfull application.

Technology Stack

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

Folder Structure

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 -build

Install Instruction

Prerequisites

Ensure 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

App Installation

  • Clone the repo in a folder
  • You must follow the installation sequence
    1. First Install Frontend
    2. Then Install Backend

To Install Frontend

# 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=false

Install Backend (SpringBoot Java)

Enabeling/Disabling spring security

to enable Spring Token security the setting

Install

# 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 API and WebUI server

# 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

Accessing Application

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'

###Screenshots Alt text

About

{frontEnd: Angular2, backEnd: java-SpringBoot, security: TokenBased JWT, liveRESTDoc: swagger-openAPI}

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 36.2%
  • TypeScript 24.0%
  • CSS 21.0%
  • HTML 18.8%