@newskit-render/mock 0.0.0-014af081
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +776 -0
- package/Dockerfile +14 -0
- package/README.md +25 -0
- package/helm/Chart.yaml +21 -0
- package/helm/templates/NOTES.txt +1 -0
- package/helm/templates/_helpers.tpl +54 -0
- package/helm/templates/deployment.yaml +31 -0
- package/helm/templates/horizontalpodautoscaler.yaml +20 -0
- package/helm/templates/networkpolicy.yaml +25 -0
- package/helm/templates/service.yaml +14 -0
- package/helm/values-dev.yaml +23 -0
- package/helm/values-local.yaml +26 -0
- package/helm/values-pr.yaml +23 -0
- package/helm/values-prod.yaml +23 -0
- package/helm/values-staging.yaml +23 -0
- package/helm/values.yaml +37 -0
- package/json-server.json +5 -0
- package/package.json +20 -0
- package/release-documentation-cli.config.json +18 -0
- package/routes.json +3 -0
- package/singular.js +19 -0
- package/src/articles/index.js +728 -0
- package/src/articles/media.js +19 -0
- package/src/index.js +5 -0
- package/src/pages/body-genarator.js +741 -0
- package/src/pages/index.js +206 -0
package/Dockerfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
FROM node:18.17-buster
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
COPY node_modules ./node_modules
|
|
6
|
+
COPY package.json ./package.json
|
|
7
|
+
COPY json-server.json ./json-server.json
|
|
8
|
+
COPY routes.json ./routes.json
|
|
9
|
+
COPY singular.js ./singular.js
|
|
10
|
+
COPY src ./src
|
|
11
|
+
|
|
12
|
+
EXPOSE 3000
|
|
13
|
+
|
|
14
|
+
ENTRYPOINT ["node", "./node_modules/.bin/json-server", "src/index.js"]
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @newskit-render/mock
|
|
2
|
+
|
|
3
|
+
Mock Rest API for our NewsKit Render Demo Site
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
use `json-server` to create two endpoint:
|
|
8
|
+
|
|
9
|
+
- articles
|
|
10
|
+
- pages
|
|
11
|
+
|
|
12
|
+
Start server with - `yarn start`
|
|
13
|
+
Go to - http://localhost:4000 to see your endpoints
|
|
14
|
+
|
|
15
|
+
http://localhost:4000/articles
|
|
16
|
+
http://localhost:4000/page
|
|
17
|
+
|
|
18
|
+
There are 10 articles you can filter from (1 to 10)
|
|
19
|
+
http://localhost:4000/articles/demo-1
|
|
20
|
+
http://localhost:4000/articles/demo-10
|
|
21
|
+
|
|
22
|
+
There are 3 pages you can filter
|
|
23
|
+
http://localhost:4000/pages/homepage
|
|
24
|
+
http://localhost:4000/pages/section-one
|
|
25
|
+
http://localhost:4000/pages/section-two
|
package/helm/Chart.yaml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
apiVersion: v2
|
|
2
|
+
name: ncu-newskit-render-mock
|
|
3
|
+
description: A NewsKit Render Helm chart for Kubernetes
|
|
4
|
+
|
|
5
|
+
# A chart can be either an 'application' or a 'library' chart.
|
|
6
|
+
#
|
|
7
|
+
# Application charts are a collection of templates that can be packaged into versioned archives
|
|
8
|
+
# to be deployed.
|
|
9
|
+
#
|
|
10
|
+
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
|
11
|
+
# a dependency of application charts to inject those utilities and functions into the rendering
|
|
12
|
+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
|
13
|
+
type: application
|
|
14
|
+
|
|
15
|
+
# This is the chart version. This version number should be incremented each time you make changes
|
|
16
|
+
# to the chart and its templates, including the app version.
|
|
17
|
+
version: 0.1.0
|
|
18
|
+
|
|
19
|
+
# This is the version number of the application being deployed. This version number should be
|
|
20
|
+
# incremented each time you make changes to the application.
|
|
21
|
+
appVersion: 0.0.1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{{/* vim: set filetype=mustache: */}}
|
|
2
|
+
{{/*
|
|
3
|
+
Expand the name of the chart.
|
|
4
|
+
*/}}
|
|
5
|
+
{{- define "mock.name" -}}
|
|
6
|
+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
|
7
|
+
{{- end -}}
|
|
8
|
+
|
|
9
|
+
{{/*
|
|
10
|
+
Create a default fully qualified app name.
|
|
11
|
+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
12
|
+
If release name contains chart name it will be used as a full name.
|
|
13
|
+
*/}}
|
|
14
|
+
{{- define "mock.fullname" -}}
|
|
15
|
+
{{- if .Values.fullnameOverride -}}
|
|
16
|
+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
|
17
|
+
{{- else -}}
|
|
18
|
+
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
|
19
|
+
{{- if contains $name .Release.Name -}}
|
|
20
|
+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
|
21
|
+
{{- else -}}
|
|
22
|
+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
|
23
|
+
{{- end -}}
|
|
24
|
+
{{- end -}}
|
|
25
|
+
{{- end -}}
|
|
26
|
+
|
|
27
|
+
{{/*
|
|
28
|
+
Create chart name and version as used by the chart label.
|
|
29
|
+
*/}}
|
|
30
|
+
{{- define "mock.chart" -}}
|
|
31
|
+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
|
32
|
+
{{- end -}}
|
|
33
|
+
|
|
34
|
+
{{/*
|
|
35
|
+
Labels
|
|
36
|
+
*/}}
|
|
37
|
+
{{- define "mock.labels" -}}
|
|
38
|
+
{{ include "mock.selectors" . }}
|
|
39
|
+
{{- if .Chart.AppVersion }}
|
|
40
|
+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
|
41
|
+
{{- end }}
|
|
42
|
+
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
43
|
+
news.co.uk/service-catalogue-id: {{ .Values.tags.serviceCatalogueId | quote }}
|
|
44
|
+
news.co.uk/service-name: {{ .Values.tags.serviceName }}
|
|
45
|
+
news.co.uk/environment: {{ .Values.environment }}
|
|
46
|
+
{{- end -}}
|
|
47
|
+
|
|
48
|
+
{{/*
|
|
49
|
+
Selector labels
|
|
50
|
+
*/}}
|
|
51
|
+
{{- define "mock.selectors" -}}
|
|
52
|
+
app.kubernetes.io/name: {{ include "mock.name" . }}
|
|
53
|
+
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
54
|
+
{{- end -}}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
apiVersion: apps/v1
|
|
2
|
+
kind: Deployment
|
|
3
|
+
metadata:
|
|
4
|
+
name: {{ include "mock.fullname" . }}
|
|
5
|
+
namespace: {{ .Values.namespace }}
|
|
6
|
+
labels: {{ include "mock.labels" . | nindent 4 }}
|
|
7
|
+
spec:
|
|
8
|
+
replicas: {{ .Values.replicaCount }}
|
|
9
|
+
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
|
|
10
|
+
selector:
|
|
11
|
+
matchLabels: {{ include "mock.selectors" . | nindent 6 }}
|
|
12
|
+
template:
|
|
13
|
+
metadata:
|
|
14
|
+
annotations:
|
|
15
|
+
{{- if eq .Values.environment "pr" }}
|
|
16
|
+
rollme: {{ randAlphaNum 5 }}
|
|
17
|
+
{{- end }}
|
|
18
|
+
labels: {{ include "mock.selectors" . | nindent 8 }}
|
|
19
|
+
spec:
|
|
20
|
+
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 8 }}
|
|
21
|
+
containers:
|
|
22
|
+
- name: {{ .Chart.Name }}
|
|
23
|
+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
|
24
|
+
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
25
|
+
ports:
|
|
26
|
+
- name: http
|
|
27
|
+
containerPort: {{ .Values.service.port }}
|
|
28
|
+
protocol: TCP
|
|
29
|
+
readinessProbe: {{ toYaml .Values.readinessProbe | nindent 12 }}
|
|
30
|
+
livenessProbe: {{ toYaml .Values.livenessProbe | nindent 12 }}
|
|
31
|
+
resources: {{ toYaml .Values.resources | nindent 12 }}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
apiVersion: autoscaling/v2
|
|
2
|
+
kind: HorizontalPodAutoscaler
|
|
3
|
+
metadata:
|
|
4
|
+
name: {{ include "mock.fullname" . }}-hpa
|
|
5
|
+
namespace: {{ .Values.namespace }}
|
|
6
|
+
labels: {{ include "mock.labels" . | nindent 4 }}
|
|
7
|
+
spec:
|
|
8
|
+
scaleTargetRef:
|
|
9
|
+
apiVersion: apps/v1
|
|
10
|
+
kind: Deployment
|
|
11
|
+
name: {{ include "mock.fullname" . }}
|
|
12
|
+
minReplicas: {{ .Values.horizontalAutoScale.min }}
|
|
13
|
+
maxReplicas: {{ .Values.horizontalAutoScale.max }}
|
|
14
|
+
metrics:
|
|
15
|
+
- type: Resource
|
|
16
|
+
resource:
|
|
17
|
+
name: {{ .Values.horizontalAutoScale.resource }}
|
|
18
|
+
target:
|
|
19
|
+
type: Utilization
|
|
20
|
+
averageUtilization: {{ .Values.horizontalAutoScale.utilization }}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{{- if .Values.networkpolicy.enabled -}}
|
|
2
|
+
{{- $fullName := include "mock.fullname" . -}}
|
|
3
|
+
apiVersion: networking.k8s.io/v1
|
|
4
|
+
kind: NetworkPolicy
|
|
5
|
+
metadata:
|
|
6
|
+
name: {{ $fullName }}-allowed-traffic
|
|
7
|
+
namespace: {{ .Values.namespace }}
|
|
8
|
+
annotations: {{ include "mock.labels" . | nindent 4 }}
|
|
9
|
+
spec:
|
|
10
|
+
podSelector:
|
|
11
|
+
matchExpressions :
|
|
12
|
+
- key: app.kubernetes.io/name
|
|
13
|
+
operator: In
|
|
14
|
+
values:
|
|
15
|
+
- {{ include "mock.name" . }}
|
|
16
|
+
ingress:
|
|
17
|
+
- ports:
|
|
18
|
+
- port: {{ .Values.service.port }}
|
|
19
|
+
protocol: TCP
|
|
20
|
+
egress:
|
|
21
|
+
- {}
|
|
22
|
+
policyTypes:
|
|
23
|
+
- Ingress
|
|
24
|
+
- Egress
|
|
25
|
+
{{- end }}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: Service
|
|
3
|
+
metadata:
|
|
4
|
+
name: {{ include "mock.fullname" . }}
|
|
5
|
+
namespace: {{ .Values.namespace }}
|
|
6
|
+
labels: {{ include "mock.labels" . | nindent 4 }}
|
|
7
|
+
spec:
|
|
8
|
+
type: {{ .Values.service.type }}
|
|
9
|
+
ports:
|
|
10
|
+
- port: {{ .Values.service.port }}
|
|
11
|
+
targetPort: {{ .Values.service.port }}
|
|
12
|
+
protocol: TCP
|
|
13
|
+
name: http
|
|
14
|
+
selector: {{ include "mock.selectors" . | nindent 4 }}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Default values for NewsKit Render.
|
|
2
|
+
# This is a YAML-formatted file.
|
|
3
|
+
# Declare variables to be passed into your templates.
|
|
4
|
+
namespace: newskit-render-dev
|
|
5
|
+
|
|
6
|
+
replicaCount: 1
|
|
7
|
+
revisionHistoryLimit: 3
|
|
8
|
+
|
|
9
|
+
resources:
|
|
10
|
+
limits:
|
|
11
|
+
cpu: 1
|
|
12
|
+
memory: 512Mi
|
|
13
|
+
requests:
|
|
14
|
+
cpu: 200m
|
|
15
|
+
memory: 256Mi
|
|
16
|
+
|
|
17
|
+
environment: dev
|
|
18
|
+
|
|
19
|
+
horizontalAutoScale:
|
|
20
|
+
min: 1
|
|
21
|
+
max: 2
|
|
22
|
+
resource: cpu
|
|
23
|
+
utilization: 60
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Default values for NewsKit Render.
|
|
2
|
+
# This is a YAML-formatted file.
|
|
3
|
+
# Declare variables to be passed into your templates.
|
|
4
|
+
namespace: newskit-render-local
|
|
5
|
+
|
|
6
|
+
replicaCount: 1
|
|
7
|
+
revisionHistoryLimit: 3
|
|
8
|
+
|
|
9
|
+
imagePullSecrets:
|
|
10
|
+
- name: regcred
|
|
11
|
+
|
|
12
|
+
resources:
|
|
13
|
+
limits:
|
|
14
|
+
cpu: 1
|
|
15
|
+
memory: 512Mi
|
|
16
|
+
requests:
|
|
17
|
+
cpu: 200m
|
|
18
|
+
memory: 256Mi
|
|
19
|
+
|
|
20
|
+
environment: local
|
|
21
|
+
|
|
22
|
+
horizontalAutoScale:
|
|
23
|
+
min: 1
|
|
24
|
+
max: 2
|
|
25
|
+
resource: cpu
|
|
26
|
+
utilization: 60
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Default values for NewsKit Render.
|
|
2
|
+
# This is a YAML-formatted file.
|
|
3
|
+
# Declare variables to be passed into your templates.
|
|
4
|
+
namespace: newskit-render-pr
|
|
5
|
+
|
|
6
|
+
replicaCount: 1
|
|
7
|
+
revisionHistoryLimit: 3
|
|
8
|
+
|
|
9
|
+
resources:
|
|
10
|
+
limits:
|
|
11
|
+
cpu: 1
|
|
12
|
+
memory: 512Mi
|
|
13
|
+
requests:
|
|
14
|
+
cpu: 200m
|
|
15
|
+
memory: 256Mi
|
|
16
|
+
|
|
17
|
+
environment: pr
|
|
18
|
+
|
|
19
|
+
horizontalAutoScale:
|
|
20
|
+
min: 1
|
|
21
|
+
max: 2
|
|
22
|
+
resource: cpu
|
|
23
|
+
utilization: 60
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Default values for NewsKit Render.
|
|
2
|
+
# This is a YAML-formatted file.
|
|
3
|
+
# Declare variables to be passed into your templates.
|
|
4
|
+
namespace: newskit-render-prod
|
|
5
|
+
|
|
6
|
+
replicaCount: 2
|
|
7
|
+
revisionHistoryLimit: 5
|
|
8
|
+
|
|
9
|
+
resources:
|
|
10
|
+
limits:
|
|
11
|
+
cpu: 1
|
|
12
|
+
memory: 512Mi
|
|
13
|
+
requests:
|
|
14
|
+
cpu: 200m
|
|
15
|
+
memory: 256Mi
|
|
16
|
+
|
|
17
|
+
environment: prod
|
|
18
|
+
|
|
19
|
+
horizontalAutoScale:
|
|
20
|
+
min: 2
|
|
21
|
+
max: 4
|
|
22
|
+
resource: cpu
|
|
23
|
+
utilization: 60
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Default values for NewsKit Render.
|
|
2
|
+
# This is a YAML-formatted file.
|
|
3
|
+
# Declare variables to be passed into your templates.
|
|
4
|
+
namespace: newskit-render-staging
|
|
5
|
+
|
|
6
|
+
replicaCount: 2
|
|
7
|
+
revisionHistoryLimit: 5
|
|
8
|
+
|
|
9
|
+
resources:
|
|
10
|
+
limits:
|
|
11
|
+
cpu: 1
|
|
12
|
+
memory: 512Mi
|
|
13
|
+
requests:
|
|
14
|
+
cpu: 200m
|
|
15
|
+
memory: 256Mi
|
|
16
|
+
|
|
17
|
+
environment: staging
|
|
18
|
+
|
|
19
|
+
horizontalAutoScale:
|
|
20
|
+
min: 2
|
|
21
|
+
max: 4
|
|
22
|
+
resource: cpu
|
|
23
|
+
utilization: 60
|
package/helm/values.yaml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
image:
|
|
2
|
+
repository: 940731442544.dkr.ecr.eu-west-1.amazonaws.com/ncu-newskit-render-mock
|
|
3
|
+
tag: ""
|
|
4
|
+
pullPolicy: Always
|
|
5
|
+
|
|
6
|
+
imagePullSecrets: []
|
|
7
|
+
nameOverride: ""
|
|
8
|
+
fullnameOverride: ""
|
|
9
|
+
|
|
10
|
+
service:
|
|
11
|
+
type: NodePort
|
|
12
|
+
port: 3000
|
|
13
|
+
|
|
14
|
+
tags:
|
|
15
|
+
serviceCatalogueId: 482
|
|
16
|
+
serviceName: newskit-render
|
|
17
|
+
|
|
18
|
+
networkpolicy:
|
|
19
|
+
enabled: true
|
|
20
|
+
annotations: {}
|
|
21
|
+
|
|
22
|
+
# Health check endpoint
|
|
23
|
+
readinessProbe:
|
|
24
|
+
httpGet:
|
|
25
|
+
path: /
|
|
26
|
+
port: 3000
|
|
27
|
+
initialDelaySeconds: 5
|
|
28
|
+
periodSeconds: 1
|
|
29
|
+
|
|
30
|
+
livenessProbe:
|
|
31
|
+
httpGet:
|
|
32
|
+
path: /
|
|
33
|
+
port: 3000
|
|
34
|
+
initialDelaySeconds: 5
|
|
35
|
+
timeoutSeconds: 2
|
|
36
|
+
periodSeconds: 3
|
|
37
|
+
failureThreshold: 5
|
package/json-server.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@newskit-render/mock",
|
|
3
|
+
"version": "0.0.0-014af081",
|
|
4
|
+
"description": "Simple rest api with mock data",
|
|
5
|
+
"author": "",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=16.13"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "json-server --watch src/index.js --port 4000",
|
|
12
|
+
"clean": "rm -rf node_modules & rm -f package-lock.json & rm -f yarn.lock"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"json-server": "0.17.3"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"gitConfigPath": "../../.git/config",
|
|
3
|
+
"releaseDetails": {
|
|
4
|
+
"emailAddress": "newskit-render@news.co.uk",
|
|
5
|
+
"title": "NewsKit Render - Mock Service",
|
|
6
|
+
"platform": "Web",
|
|
7
|
+
"osType": "AWS",
|
|
8
|
+
"partner": "Internal (NewsUK Teams)",
|
|
9
|
+
"priority": "P2 - Very Important release required (3-4 days)",
|
|
10
|
+
"businessJustification": "This release is to deliver performance improvements, feature enhancements and bug fixes for NewsKit Render",
|
|
11
|
+
"testingMethod": "Both",
|
|
12
|
+
"testingToolsUsed": "Jest",
|
|
13
|
+
"releaseDurationMinutes": 15,
|
|
14
|
+
"appIds": ["NUK482"],
|
|
15
|
+
"environment": "Production"
|
|
16
|
+
},
|
|
17
|
+
"localChangelogPath": "./CHANGELOG.md"
|
|
18
|
+
}
|
package/routes.json
ADDED
package/singular.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = (req, res, next) => {
|
|
2
|
+
const _send = res.send;
|
|
3
|
+
res.send = function (body) {
|
|
4
|
+
if (require("url").parse(req.originalUrl, true).query["singular"]) {
|
|
5
|
+
try {
|
|
6
|
+
const json = JSON.parse(body);
|
|
7
|
+
if (Array.isArray(json)) {
|
|
8
|
+
if (json.length === 1) {
|
|
9
|
+
return _send.call(this, JSON.stringify(json[0]));
|
|
10
|
+
} else if (json.length === 0) {
|
|
11
|
+
return _send.call(this, "{}", 404);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
} catch (e) {}
|
|
15
|
+
}
|
|
16
|
+
return _send.call(this, body);
|
|
17
|
+
};
|
|
18
|
+
next();
|
|
19
|
+
};
|