A service to receive test results from the MES mobile app.
All serverless functions live in dedicated directories in src/functions
.
Code that is common between multiple functions should reside in src/common
.
As per the principles of Hexagonal Architecture, each function has the following directories to help us separate concerns:
framework
- contains all Inbound and Outbound Adapters, and all use of external/proprietary APIs - depends upon...application
- contains all Inbound and Outbound Ports, doesn't use any external/proprietary APIs - depends upon...domain
- contains all domain objects (Aggregates, Objects, Value classes etc) with all "business logic" (not just anaemic data holders), doesn't use any external/proprietary APIs.
To allow development to take place locally without re-deploying new versions to AWS for every code change a local mysql database can be created and a local env file used to connect serverless to it.
This will docker to be installed and service running locally. (For mac suggest docker desktop)
Data can be added amended to the appropriate sql files under /docker/results_database
In new terminal:
cd docker
docker compose up
When finished to clean up after yourself:
docker compose down
To run serverless locally run the following command which will allow services to be accessed via a tool such as postman.
npm start
To build a zip file for every function to artifacts
, run:
npm run package
To build a subset of the functions, pass a comma separated list of function names, like so:
npm run package -- get,set
N.b. The build requires jq.
Any functions delcared in serverless.yml that contain the word "local" will be ignored in the packaging process.
To run the unit tests, simply run:
npm test
There are some integration tests, each of which can be found in the __tests__
directory of the source tree with the .int.ts
extension.
A pre-requisite for running these integration tests is that you have a Docker container running MySQL locally.
cd spec/infra
docker-compose up
The integration tests can then be run with:
npm run test:int
Note, the database container should be destroyed after each test run to ensure the state is clean:
cd spec/infra
docker-compose down