This API provides an interface for calculating charges, queuing transactions and generating transaction files used to produce invoices.
Make sure you already have:
First clone the repository and then drop into your new local repo:
git clone https://github.com/DEFRA/sroc-charging-module-api.git && cd sroc-charging-module-api
Our preference is to run the database and API within Docker, so install Docker if you don't already have it.
Any configuration is expected to be driven by environment variables when the service is run in production as per 12 factor app.
However when running locally in development mode or in test it makes use of the Dotenv package. This is a shim that will load values stored in a .env
file into the environment which the service will then pick up as though they were there all along.
Check out .env.example for details of the required things you'll need in your .env
file.
Refer to the config files for details of all the configuration used.
As Docker is our chosen solution for deploying and managing the app in production we also use it for local development. The following will get an environment up and running quickly ready for development. It assumes 2 things
- you have Docker installed
- you are using VSCode for development
Open the project in VSCode and then use the Command palette to access the tasks we have provided in tasks.json
With the palette open search for Run test task and once highlighted select it. From the list that's presented select ⬆️ UP (CMA)
You should see a new terminal open up and Docker Compose begin to start building the images. Once that is done it will switch to running the API in docker.
The main database is automatically created but the 'test' database is not. Plus both need the DB migrations to be run against them, and the main database needs to be seeded.
The good news is all this is automated. Again, using the command palette and the Run test task option find and select 🗄️ DB (CMA). It will setup both databases and leave the API ready for use.
You can also use this same command to reset the databases at anytime
If you are not a VSCode user it does not mean you cannot use Docker. Refer to tasks.json for the commands being run and implement them in your preferred tool.
To run lint checks use the command palette and the Run test task option to find and select
- 🔎 LINT (CMA)
To run unit tests find and select
- ✅ TEST (CMA)
Check out the scripts
in package.json if you intend to run things locally.
If you have an idea you'd like to contribute please log an issue.
All contributions should be submitted via a pull request.
THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:
http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3
The following attribution statement MUST be cited in your products and applications when using this information.
Contains public sector information licensed under the Open Government license v3
The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.
It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.