Skip to content

Commit

Permalink
SFD-3376 Create postcode mapping repo (#3)
Browse files Browse the repository at this point in the history
* Added application code

* Added application code

* Add application code

* Add ignore file

* task/SFD-3376_Create postcode mapping repo with basic functionality without Auth

* task/SFD-3376_Ccg reference and the profile check removed

* task/SFD-3376_Authentication and Authorisation changes

* task/SFD-3376_Role name changed accordingly

* task/SFD-3376_Review comments fixes

* SFD-3376 Git ignored removed from automation directory

* SFD-3376 Make file indentation set right

* SFD-3376 Make file indentation set right and tab spaces fixes

* SFD-3376 Sonarqube fixes

* SFD-3376 Java documentation added

* SFD-3376 More sonar fixes included

* Exclude java files from analysis for now

Co-authored-by: Jonathan Pearce <j.pearce1@nhs.net>
  • Loading branch information
ArifNhs and jope1 authored Sep 13, 2021
1 parent 38b6460 commit 41a596c
Show file tree
Hide file tree
Showing 43 changed files with 1,363 additions and 23 deletions.
1 change: 1 addition & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ jobs:
args: >
-Dsonar.organization=nhsd-exeter
-Dsonar.projectKey=dos-postcode-api
-Dsonar.exclusions=**/*.java
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "java",
"name": "Debug (Launch)-DosPostcodeApi<dos-postcode-api>",
"request": "launch",
"mainClass": "uk.nhs.digital.uec.api.PostcodeMappingApplication",
"projectName": "dos-postcode-api",
"env": {
"SERVER_PORT": 8443
}
}
]
}
46 changes: 40 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,26 @@ include $(abspath $(PROJECT_DIR)/build/automation/init.mk)
# ==============================================================================
# Development workflow targets

build: project-config # Build project
make docker-build NAME=NAME_TEMPLATE_TO_REPLACE

start: project-start # Start project
build: project-config
cp \
$(PROJECT_DIR)/build/automation/etc/certificate/* \
$(PROJECT_DIR)/application/src/main/resources/certificate
make docker-run-mvn \
DIR="application" \
CMD="-Dmaven.test.skip=true clean install"
mv \
$(PROJECT_DIR)/application/target/dos-postcode-api-*.jar \
$(PROJECT_DIR)/build/docker/dos-postcode-api/assets/application/dos-postcode-api.jar
make docker-build NAME=dos-postcode-api

start: project-start # Start project
make local-dynamodb-scripts

local-dynamodb-scripts:
cd $(PROJECT_DIR)data/dynamo/test
chmod +x *.sh
./00-postcode-location-mapping-table.sh > /dev/null
./01-postcode-location-mapping-table.sh

stop: project-stop # Stop project

Expand All @@ -20,11 +36,14 @@ test: # Test project
make stop

push: # Push project artefacts to the registry
make docker-push NAME=NAME_TEMPLATE_TO_REPLACE
make docker-push NAME=dos-postcode-api

deploy: # Deploy artefacts - mandatory: PROFILE=[name]
make project-deploy STACK=application PROFILE=$(PROFILE)

provision-plan:
make terraform-plan STACK=database PROFILE=$(PROFILE)

provision: # Provision environment - mandatory: PROFILE=[name]
make terraform-apply-auto-approve STACK=database PROFILE=$(PROFILE)

Expand Down Expand Up @@ -138,4 +157,19 @@ pipeline-create-resources: ## Create all the pipeline deployment supporting reso

# ==============================================================================

.SILENT:
derive-build-tag:
dir=$$(make _docker-get-dir NAME=dos-postcode-api)
echo $$(cat $$dir/VERSION) | \
sed "s/YYYY/$$(date --date=$(BUILD_DATE) -u +"%Y")/g" | \
sed "s/mm/$$(date --date=$(BUILD_DATE) -u +"%m")/g" | \
sed "s/dd/$$(date --date=$(BUILD_DATE) -u +"%d")/g" | \
sed "s/HH/$$(date --date=$(BUILD_DATE) -u +"%H")/g" | \
sed "s/MM/$$(date --date=$(BUILD_DATE) -u +"%M")/g" | \
sed "s/ss/$$(date --date=$(BUILD_DATE) -u +"%S")/g" | \
sed "s/SS/$$(date --date=$(BUILD_DATE) -u +"%S")/g" | \
sed "s/hash/$$(git rev-parse --short HEAD)/g"

# ==============================================================================

.SILENT: \
derive-build-tag
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,17 @@

## Overview

A few sentences what business problem this project solves...
This is the DoS Postcode API. A number of Service Searches require a point to point distance from the search postcode to the services meeting the search criteria to be calculated and returned. To perform this task the northing and easting location coordinates are required. This API will return northing and easting coordinates for any given UK postcode.

## Quick Start

Run the following make targets:
- make build
- make start

The API can be reached on this endpoint:

https://localhost:8443/api/search?postcodes=<postcode>
### Development Requirements

- macOS operating system provisioned with the `curl -L bit.ly/make-devops-macos-setup | bash` command
Expand Down
36 changes: 36 additions & 0 deletions application/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

#SSL certificates
certificate.*
182 changes: 182 additions & 0 deletions application/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8" ?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>

<properties>
<hibernate.version>4.3.6.Final</hibernate.version>
<mockito.version>3.7.7</mockito.version>
<aws-java-sdk-dynamodb.version>1.11.948</aws-java-sdk-dynamodb.version>
<aws-java-sdk-sts.version>1.11.699</aws-java-sdk-sts.version>
<spring-data-dynamodb.version>5.2.1</spring-data-dynamodb.version>
<amazon.awssdk.sts.version>2.10.40</amazon.awssdk.sts.version>
<spring-data-jpa.version>2.4.3</spring-data-jpa.version>
<mockito-junit-jupiter.version>2.23.4</mockito-junit-jupiter.version>
<commons-lang3.version>3.11</commons-lang3.version>
<commons-collections4.version>4.4</commons-collections4.version>
<springdoc-openapi-ui.version>1.5.2</springdoc-openapi-ui.version>
</properties>

<groupId>uec</groupId>
<artifactId>dos-postcode-api</artifactId>
<version>1.0.0</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.3</version>
<relativePath/>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>2.4.3</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-dynamodb -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
<version>${aws-java-sdk-dynamodb.version}</version>
</dependency>

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sts</artifactId>
<version>${aws-java-sdk-sts.version}</version>
</dependency>

<dependency>
<groupId>io.github.boostchicken</groupId>
<artifactId>spring-data-dynamodb</artifactId>
<version>${spring-data-dynamodb.version}</version>
</dependency>

<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sts</artifactId>
<version>${amazon.awssdk.sts.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${spring-data-jpa.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito-junit-jupiter.version}</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>

<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.18.1</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>${commons-collections4.version}</version>
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc-openapi-ui.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package uk.nhs.digital.uec.api;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
import uk.nhs.digital.uec.api.config.DynamoConfig;

@SpringBootApplication
@Import(DynamoConfig.class)
public class PostcodeMappingApplication {

public static void main(String[] args) {
SpringApplication app = new SpringApplication(PostcodeMappingApplication.class);
app.setAdditionalProfiles("ssl");
app.run(args);
}
}
Loading

0 comments on commit 41a596c

Please sign in to comment.