Skip to content

Commit b80c4d3

Browse files
Signed commit for Get Application release (#4)
Get & Fetch Applications through message queue.
1 parent 1b7173c commit b80c4d3

File tree

100 files changed

+9883
-621
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+9883
-621
lines changed

.gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1+
# Test output
2+
html-reports
13
test-output
4+
5+
# npm stuff
6+
.npm/
27
node_modules
8+
npm-debug.log
9+
10+
# Misc
311
helm/**/*.lock
412
*.tgz
13+
.env
14+
*.log
15+
16+
# Editor stuff
517
.vscode
18+
dist/
19+
20+
# Generated views
21+
layout.njk
22+
23+
# OS stuff
24+
.DS_Store

.secrets.baseline

+28-2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,32 @@
104104
"path": "detect_secrets.filters.heuristic.is_templated_secret"
105105
}
106106
],
107-
"results": {},
108-
"generated_at": "2022-02-22T08:52:45Z"
107+
"results": {
108+
"docker-compose.yaml": [
109+
{
110+
"type": "Secret Keyword",
111+
"filename": "docker-compose.yaml",
112+
"hashed_secret": "5301b0b64604e377783a16f7feb7a8a3d1512697",
113+
"is_verified": false,
114+
"line_number": 15
115+
}
116+
],
117+
"helm/ffc-ahwr-backoffice/values.yaml": [
118+
{
119+
"type": "Secret Keyword",
120+
"filename": "helm/ffc-ahwr-backoffice/values.yaml",
121+
"hashed_secret": "5301b0b64604e377783a16f7feb7a8a3d1512697",
122+
"is_verified": false,
123+
"line_number": 28
124+
},
125+
{
126+
"type": "Secret Keyword",
127+
"filename": "helm/ffc-ahwr-backoffice/values.yaml",
128+
"hashed_secret": "b840fc02d524045429941cc15f59e41cb7be6c52",
129+
"is_verified": false,
130+
"line_number": 38
131+
}
132+
]
133+
},
134+
"generated_at": "2022-06-14T11:03:59Z"
109135
}

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ EXPOSE ${PORT} ${PORT_DEBUG}
1515
COPY --chown=node:node package*.json ./
1616
RUN npm install
1717
COPY --chown=node:node . .
18+
RUN npm run build
1819
CMD [ "npm", "run", "start:watch" ]
1920

2021
# Production

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ The script will update the following:
1515
* `docker-compose.yaml`: update the service name, `image` and `container_name`
1616
* `docker-compose.test.yaml`: update the service name, `image` and `container_name`
1717
* `docker-compose.override.yaml`: update the service name, `image` and `container_name`
18-
* Rename `helm/ffc-template-node`
19-
* `helm/ffc-template-node/Chart.yaml`: update `description` and `name`
20-
* `helm/ffc-template-node/values.yaml`: update `name`, `namespace`, `workstream`, `image`, `containerConfigMap.name`
21-
* `helm/ffc-template-node/templates/_container.yaml`: update the template name
22-
* `helm/ffc-template-node/templates/cluster-ip-service.yaml`: update the template name and list parameter of include
23-
* `helm/ffc-template-node/templates/config-map.yaml`: update the template name and list parameter of include
24-
* `helm/ffc-template-node/templates/deployment.yaml`: update the template name, list parameter of deployment and container includes
18+
* Rename `helm/ffc-ahwr-backoffice`
19+
* `helm/ffc-ahwr-backoffice/Chart.yaml`: update `description` and `name`
20+
* `helm/ffc-ahwr-backoffice/values.yaml`: update `name`, `namespace`, `workstream`, `image`, `containerConfigMap.name`
21+
* `helm/ffc-ahwr-backoffice/templates/_container.yaml`: update the template name
22+
* `helm/ffc-ahwr-backoffice/templates/cluster-ip-service.yaml`: update the template name and list parameter of include
23+
* `helm/ffc-ahwr-backoffice/templates/config-map.yaml`: update the template name and list parameter of include
24+
* `helm/ffc-ahwr-backoffice/templates/deployment.yaml`: update the template name, list parameter of deployment and container includes
2525

2626
### Notes on automated rename
2727

28-
* The Helm chart deployment values in `helm/ffc-template-node/values.yaml` may need updating depending on the resource needs of your microservice
28+
* The Helm chart deployment values in `helm/ffc-ahwr-backoffice/values.yaml` may need updating depending on the resource needs of your microservice
2929
* The rename is a one-way operation i.e. currently it doesn't allow the name being changed from to be specified
3030
* There is some validation on the input to try and ensure the rename is successful, however, it is unlikely to stand up to malicious entry
3131
* Once the rename has been performed the script can be removed from the repo

app/config/index.js

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
const Joi = require('joi')
2+
const msgTypePrefix = 'uk.gov.ffc.ahwr'
3+
4+
const sharedConfigSchema = {
5+
appInsights: Joi.object(),
6+
host: Joi.string().default('localhost'),
7+
password: Joi.string(),
8+
username: Joi.string(),
9+
useCredentialChain: Joi.bool().default(false)
10+
}
11+
const schema = Joi.object({
12+
cache: {
13+
expiresIn: Joi.number().default(1000 * 3600 * 24 * 3), // 3 days
14+
options: {
15+
host: Joi.string().default('redis-hostname.default'),
16+
partition: Joi.string().default('ffc-ahwr-backoffice'),
17+
password: Joi.string().allow(''),
18+
port: Joi.number().default(6379),
19+
tls: Joi.object()
20+
}
21+
},
22+
cookie: {
23+
cookieNameCookiePolicy: Joi.string().default('ffc_ahwr_backoffice_cookie_policy'),
24+
cookieNameAuth: Joi.string().default('ffc_ahwr_backoffice_auth'),
25+
cookieNameSession: Joi.string().default('ffc_ahwr_backoffice_session'),
26+
isSameSite: Joi.string().default('Lax'),
27+
isSecure: Joi.boolean().default(true),
28+
password: Joi.string().min(32).required(),
29+
ttl: Joi.number().default(1000 * 3600 * 24 * 3) // 3 days
30+
},
31+
cookiePolicy: {
32+
clearInvalid: Joi.bool().default(false),
33+
encoding: Joi.string().valid('base64json').default('base64json'),
34+
isSameSite: Joi.string().default('Lax'),
35+
isSecure: Joi.bool().default(true),
36+
password: Joi.string().min(32).required(),
37+
path: Joi.string().default('/'),
38+
ttl: Joi.number().default(1000 * 60 * 60 * 24 * 365) // 1 year
39+
},
40+
env: Joi.string().valid('development', 'test', 'production').default('development'),
41+
isDev: Joi.boolean().default(false),
42+
port: Joi.number().default(3000),
43+
serviceName: Joi.string().default('Administration of the health and welfare of your livestock'),
44+
backOfficeRequestQueue: {
45+
address: Joi.string().default('backOfficeRequestQueue'),
46+
type: Joi.string(),
47+
...sharedConfigSchema
48+
},
49+
backOfficeRequestMsgType: Joi.string(),
50+
getApplicationRequestMsgType: Joi.string(),
51+
backOfficeResponseQueue: {
52+
address: Joi.string().default('backOfficeResponseQueue'),
53+
type: Joi.string(),
54+
...sharedConfigSchema
55+
},
56+
backOfficeResponseMsgType: Joi.string(),
57+
getBackOfficeApplicationResponseMsgType: Joi.string(),
58+
serviceUri: Joi.string().uri(),
59+
useRedis: Joi.boolean().default(false)
60+
})
61+
62+
const sharedConfig = {
63+
appInsights: require('applicationinsights'),
64+
host: process.env.MESSAGE_QUEUE_HOST,
65+
password: process.env.MESSAGE_QUEUE_PASSWORD,
66+
username: process.env.MESSAGE_QUEUE_USER,
67+
useCredentialChain: process.env.NODE_ENV === 'production'
68+
}
69+
const config = {
70+
cache: {
71+
options: {
72+
host: process.env.REDIS_HOSTNAME,
73+
password: process.env.REDIS_PASSWORD,
74+
port: process.env.REDIS_PORT,
75+
tls: process.env.NODE_ENV === 'production' ? {} : undefined
76+
}
77+
},
78+
cookie: {
79+
cookieNameCookiePolicy: 'ffc_ahwr_backoffice_cookie_policy',
80+
cookieNameAuth: 'ffc_ahwr_backoffice_auth',
81+
cookieNameSession: 'ffc_ahwr_backoffice_session',
82+
isSameSite: 'Lax',
83+
isSecure: process.env.NODE_ENV === 'production',
84+
password: process.env.COOKIE_PASSWORD
85+
},
86+
cookiePolicy: {
87+
clearInvalid: false,
88+
encoding: 'base64json',
89+
isSameSite: 'Lax',
90+
isSecure: process.env.NODE_ENV === 'production',
91+
password: process.env.COOKIE_PASSWORD
92+
},
93+
env: process.env.NODE_ENV,
94+
isDev: process.env.NODE_ENV === 'development',
95+
port: process.env.PORT,
96+
backOfficeRequestQueue: {
97+
address: process.env.BACKOFFICEREQUEST_QUEUE_ADDRESS,
98+
type: 'queue',
99+
...sharedConfig
100+
},
101+
backOfficeRequestMsgType: `${msgTypePrefix}.backoffice.request`,
102+
getApplicationRequestMsgType: `${msgTypePrefix}.get.application.backoffice.request`,
103+
getBackOfficeApplicationResponseMsgType: `${msgTypePrefix}.get.application.backoffice.response`,
104+
backOfficeResponseQueue: {
105+
address: process.env.BACKOFFICERESPONSE_QUEUE_ADDRESS,
106+
type: 'queue',
107+
...sharedConfig
108+
},
109+
backOfficeResponseMsgType: `${msgTypePrefix}.backoffice.response`,
110+
serviceUri: process.env.SERVICE_URI,
111+
useRedis: process.env.NODE_ENV !== 'test'
112+
}
113+
114+
const { error, value } = schema.validate(config, { abortEarly: false })
115+
116+
if (error) {
117+
throw new Error(`The server config is invalid. ${error.message}`)
118+
}
119+
120+
module.exports = value

app/cookies.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { cookie: { cookieNameCookiePolicy } } = require('./config')
2+
3+
function getCurrentPolicy (request, h) {
4+
let cookiesPolicy = request.state[cookieNameCookiePolicy]
5+
if (!cookiesPolicy) {
6+
cookiesPolicy = createDefaultPolicy(h)
7+
}
8+
return cookiesPolicy
9+
}
10+
11+
function createDefaultPolicy (h) {
12+
const cookiesPolicy = { confirmed: false, essential: true, analytics: false }
13+
h.state(cookieNameCookiePolicy, cookiesPolicy)
14+
return cookiesPolicy
15+
}
16+
17+
function updatePolicy (request, h, analytics) {
18+
const cookiesPolicy = getCurrentPolicy(request, h)
19+
20+
cookiesPolicy.analytics = analytics
21+
cookiesPolicy.confirmed = true
22+
23+
h.state(cookieNameCookiePolicy, cookiesPolicy)
24+
}
25+
26+
module.exports = {
27+
getCurrentPolicy,
28+
updatePolicy
29+
}
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Task list pattern
2+
3+
.app-task-list {
4+
list-style-type: none;
5+
padding-left: 0;
6+
margin-top: 0;
7+
margin-bottom: 0;
8+
@include govuk-media-query($from: tablet) {
9+
min-width: 550px;
10+
}
11+
}
12+
13+
.app-task-list__section {
14+
display: table;
15+
@include govuk-font($size:24, $weight: bold);
16+
}
17+
18+
.app-task-list__section-number {
19+
display: table-cell;
20+
21+
@include govuk-media-query($from: tablet) {
22+
min-width: govuk-spacing(6);
23+
padding-right: 0;
24+
}
25+
}
26+
27+
.app-task-list__items {
28+
@include govuk-font($size: 19);
29+
@include govuk-responsive-margin(9, "bottom");
30+
list-style: none;
31+
padding-left: 0;
32+
@include govuk-media-query($from: tablet) {
33+
padding-left: govuk-spacing(6);
34+
}
35+
}
36+
37+
.app-task-list__item {
38+
border-bottom: 1px solid $govuk-border-colour;
39+
margin-bottom: 0 !important;
40+
padding-top: govuk-spacing(2);
41+
padding-bottom: govuk-spacing(2);
42+
@include govuk-clearfix;
43+
}
44+
45+
.app-task-list__item:first-child {
46+
border-top: 1px solid $govuk-border-colour;
47+
}
48+
49+
.app-task-list__task-name {
50+
display: block;
51+
@include govuk-media-query($from: 450px) {
52+
float: left;
53+
}
54+
}
55+
56+
// The `app-task-list__task-completed` class was previously used on the task
57+
// list for the completed tag (changed in 86c90ec) – it's still included here to
58+
// avoid breaking task lists in existing prototypes.
59+
.app-task-list__tag,
60+
.app-task-list__task-completed {
61+
margin-top: govuk-spacing(2);
62+
margin-bottom: govuk-spacing(1);
63+
64+
@include govuk-media-query($from: 450px) {
65+
float: right;
66+
margin-top: 0;
67+
margin-bottom: 0;
68+
}
69+
}

0 commit comments

Comments
 (0)