Skip to content

Commit 31ccaad

Browse files
committed
initial commit - migrating content from eligibility-signposting-api
1 parent ba608d6 commit 31ccaad

37 files changed

+9758
-12
lines changed

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Docker Host for Lambda Execution
2+
DOCKER_HOST=unix:///var/run/docker.sock
3+
4+

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
!project.code-workspace
1212

1313
# Please, add your custom content below!
14+
node_modules
15+
build
16+
sandbox/tests
17+
sandbox/__pycache__

Makefile

Lines changed: 113 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,132 @@
11
# This file is for you! Edit it to implement your own hooks (make targets) into
22
# the project as automated steps to be executed on locally and in the CD pipeline.
3-
3+
# ==============================================================================
44
include scripts/init.mk
55

6-
# ==============================================================================
6+
MAKE_DIR := $(abspath $(shell pwd))
7+
8+
#Installs dependencies using poetry.
9+
install-python:
10+
poetry install
11+
12+
#Installs dependencies using npm.
13+
install-node:
14+
npm install --legacy-peer-deps
15+
16+
#Configures Git Hooks, which are scripts that run given a specified event.
17+
.git/hooks/pre-commit:
18+
cp scripts/pre-commit .git/hooks/pre-commit
19+
20+
#Condensed Target to run all targets above.
21+
install: install-node install-python .git/hooks/pre-commit
22+
23+
#Run the npm linting script (specified in package.json). Used to check the syntax and formatting of files.
24+
lint:
25+
# npm run lint
26+
poetry run ruff format . --check
27+
poetry run ruff check .
28+
poetry run pyright
29+
30+
31+
format: ## Format and fix code
32+
poetry run ruff format .
33+
poetry run ruff check . --fix-only
34+
35+
#Creates the fully expanded OAS spec in json
36+
publish: clean
37+
mkdir -p build
38+
mkdir -p sandbox/specification
39+
npm run publish 2> /dev/null
40+
cp build/eligibility-signposting-api.json sandbox/specification/eligibility-signposting-api.json
41+
#Files to loop over in release
42+
_dist_include="pytest.ini poetry.lock poetry.toml pyproject.toml Makefile build/. tests"
743

844
# Example CI/CD targets are: dependencies, build, publish, deploy, clean, etc.
945

1046
dependencies: # Install dependencies needed to build and test the project @Pipeline
11-
# TODO: Implement installation of your project dependencies
12-
13-
build: # Build the project artefact @Pipeline
14-
# TODO: Implement the artefact build step
47+
scripts/dependencies.sh
1548

16-
publish: # Publish the project artefact @Pipeline
17-
# TODO: Implement the artefact publishing step
1849

19-
deploy: # Deploy the project artefact to the target environment @Pipeline
20-
# TODO: Implement the artefact deployment step
2150

22-
clean:: # Clean-up project resources (main) @Operations
23-
# TODO: Implement project resources clean-up step
2451

2552
config:: # Configure development environment (main) @Configuration
2653
# TODO: Use only 'make' targets that are specific to this project, e.g. you may not need to install Node.js
2754
make _install-dependencies
2855

56+
##################
57+
#### Proxygen ####
58+
##################
59+
60+
retrieve-proxygen-key: # Obtain the 'machine user' credentials from AWS SSM (Development environment)
61+
mkdir -p ~/.proxygen && \
62+
aws ssm get-parameter --name /proxygen/private_key_temp --with-decryption | jq ".Parameter.Value" --raw-output \
63+
> ~/.proxygen/eligibility-signposting-api.pem
64+
65+
setup-proxygen-credentials: # Copy Proxygen templated credentials to where it expected them
66+
cd specification && cp -r .proxygen ~
67+
68+
get-spec: # Get the most recent specification live in proxygen
69+
$(MAKE) setup-proxygen-credentials
70+
proxygen spec get
71+
72+
# Specification
73+
74+
guard-%:
75+
@ if [ "${${*}}" = "" ]; then \
76+
echo "Variable $* not set"; \
77+
exit 1; \
78+
fi
79+
80+
set-target: guard-APIM_ENV
81+
@ TARGET=target-$$APIM_ENV.yaml \
82+
envsubst '$${TARGET}' \
83+
< specification/x-nhsd-apim/target-template.yaml > specification/x-nhsd-apim/target.yaml
84+
85+
set-access: guard-APIM_ENV
86+
@ ACCESS=access-$$APIM_ENV.yaml \
87+
envsubst '$${ACCESS}' \
88+
< specification/x-nhsd-apim/access-template.yaml > specification/x-nhsd-apim/access.yaml
89+
90+
set-security: guard-APIM_ENV
91+
@ SECURITY=security-$$APIM_ENV.yaml \
92+
envsubst '$${SECURITY}' \
93+
< specification/components/security/security-template.yaml > specification/components/security/security.yaml
94+
95+
set-ratelimit: guard-APIM_ENV
96+
@ RATELIMIT=ratelimit-$$APIM_ENV.yaml \
97+
envsubst '$${RATELIMIT}' \
98+
< specification/x-nhsd-apim/ratelimit-template.yaml > specification/x-nhsd-apim/ratelimit.yaml
99+
100+
update-spec-template: guard-APIM_ENV
101+
ifeq ($(APIM_ENV), $(filter $(APIM_ENV), sandbox internal-dev int ref prod ))
102+
@ $(MAKE) set-target APIM_ENV=$$APIM_ENV
103+
@ $(MAKE) set-access APIM_ENV=$$APIM_ENV
104+
@ $(MAKE) set-security APIM_ENV=$$APIM_ENV
105+
@ $(MAKE) set-ratelimit APIM_ENV=$$APIM_ENV
106+
else
107+
@ echo ERROR: $$APIM_ENV is not a valid environment. Please use one of [sandbox, internal-dev, int, ref, prod]
108+
@ exit 1;
109+
endif
110+
111+
construct-spec: guard-APIM_ENV
112+
@ $(MAKE) update-spec-template APIM_ENV=$$APIM_ENV
113+
mkdir -p build/specification && \
114+
npx redocly bundle specification/eligibility-signposting-api.yaml --remove-unused-components --keep-url-references --ext yaml \
115+
> build/specification/eligibility-signposting-api.yaml
116+
ifeq ($(APIM_ENV), sandbox)
117+
@ $(MAKE) publish
118+
endif
119+
120+
SPEC_DIR := $(CURDIR)/specification
121+
POSTMAN_DIR := $(SPEC_DIR)/postman
122+
123+
convert-postman: # Create Postman collection from OAS spec
124+
mkdir -p $(POSTMAN_DIR)
125+
cp $(SPEC_DIR)/eligibility-signposting-api.yaml $(POSTMAN_DIR)/
126+
docker build -t portman-converter -f $(POSTMAN_DIR)/Dockerfile $(SPEC_DIR)
127+
docker run --rm -v $(SPEC_DIR):/app portman-converter \
128+
portman -l /app/eligibility-signposting-api.yaml -o /app/postman/collection.json
129+
rm $(POSTMAN_DIR)/eligibility-signposting-api.yaml
29130
# ==============================================================================
30131

31132
${VERBOSE}.SILENT: \

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Make use of this repository template to expedite your project setup and enhance
2323
- [Configuration](#configuration)
2424
- [Usage](#usage)
2525
- [Testing](#testing)
26+
- [Sandbox](#sandbox)
27+
- [Specification](#specification)
2628
- [Design](#design)
2729
- [Diagrams](#diagrams)
2830
- [Modularity](#modularity)
@@ -83,6 +85,15 @@ After a successful installation, provide an informative example of how this proj
8385

8486
There are `make` tasks for you to configure to run your tests. Run `make test` to see how they work. You should be able to use the same entry points for local development as in your CI pipeline.
8587

88+
## Sandbox
89+
90+
There is a minimalist sandbox environment in `/sandbox` with an accompanying README with instructions on how to run it locally.
91+
92+
## Specification
93+
94+
The OpenAPI specification is stored in `specification`. In that folder, there is an accompanying README with instructions on how to produce an environment-specification specification and publish
95+
it using Proxygen CLI.
96+
8697
## Design
8798

8899
### Diagrams

0 commit comments

Comments
 (0)