-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from DEFRA/inital-development
Inital development
- Loading branch information
Showing
42 changed files
with
4,082 additions
and
230 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,163 +1,69 @@ | ||
# CDP Node Backend Template | ||
|
||
Core delivery platform Node.js Backend Template. | ||
|
||
- [Requirements](#requirements) | ||
- [Node.js](#nodejs) | ||
- [Local development](#local-development) | ||
- [Setup](#setup) | ||
- [Development](#development) | ||
- [Production](#production) | ||
- [Npm scripts](#npm-scripts) | ||
- [API endpoints](#api-endpoints) | ||
- [Calling API endpoints](#calling-api-endpoints) | ||
- [Postman](#postman) | ||
- [Versioning](#versioning) | ||
- [Auto minor versioning](#auto-minor-versioning) | ||
- [Major or Patch versioning](#major-or-patch-versioning) | ||
- [Docker](#docker) | ||
- [Development Image](#development-image) | ||
- [Production Image](#production-image) | ||
- [Licence](#licence) | ||
- [About the licence](#about-the-licence) | ||
|
||
## Requirements | ||
|
||
### Node.js | ||
|
||
Please install [Node.js](http://nodejs.org/) `>= v18` and [npm](https://nodejs.org/) `>= v9`. You will find it | ||
easier to use the Node Version Manager [nvm](https://github.com/creationix/nvm) | ||
|
||
To use the correct version of Node.js for this application, via nvm: | ||
# CDP Portal Stubs | ||
|
||
```bash | ||
$ cd cdp-portal-stubs | ||
$ nvm use | ||
``` | ||
|
||
## Local development | ||
A set of stubs for mocking out calls to github & aws for the cdp-portal. | ||
|
||
### Setup | ||
## Setup | ||
|
||
Install application dependencies: | ||
|
||
```bash | ||
$ npm install | ||
``` | ||
### start defra-mock-oidc-server | ||
|
||
### Development | ||
### start mongo, redis, localstack | ||
|
||
To run the application in `development` mode run: | ||
### create queues | ||
|
||
```bash | ||
$ npm run dev | ||
``` | ||
### start cdp-portal-backend | ||
|
||
### Production | ||
### start cdp-self-service-ops | ||
|
||
To mimic the application running in `production` mode locally run: | ||
Override the following config items: | ||
|
||
```bash | ||
$ npm start | ||
export GITHUB_BASE_URL=http://localhost:3939 | ||
export OIDC_ISSUER_BASE_URL=http://127.0.0.1:5557/oidc | ||
export OIDC_KEYS_URL=http://127.0.0.1:5557/oidc/.well-known/jwks.json | ||
``` | ||
|
||
### Npm scripts | ||
### cdp-user-services | ||
|
||
All available Npm scripts can be seen in [package.json](./package.json) | ||
To view them in your command line run: | ||
Override the following config items: | ||
|
||
```bash | ||
$ npm run | ||
export AZURE_CLIENT_SECRET=test_value | ||
export OIDC_ISSUER_BASE_URL=http://127.0.0.1:5557/oidc | ||
export OIDC_KEYS_URL=http://127.0.0.1:5557/oidc/.well-known/jwks.json | ||
``` | ||
|
||
## API endpoints | ||
|
||
| Endpoint | Description | | ||
| :----------------------------- | :----------- | | ||
| `GET: /health` | Health | | ||
| `GET: /v1/entities` | Entities | | ||
| `GET: /v1/entities/<entityId>` | Entity by ID | | ||
|
||
## Calling API endpoints | ||
### start cdp-portal-frontend | ||
|
||
### Postman | ||
|
||
A [Postman](https://www.postman.com/) collection and environment are available for making calls to the Teams and | ||
Repositories API. Simply import the collection and environment into Postman. | ||
|
||
- [CDP Node Backend Template Postman Collection](postman/cdp-portal-stubs.postman_collection.json) | ||
- [CDP Node Backend Template Postman Environment](postman/cdp-portal-stubs.postman_environment.json) | ||
|
||
## Versioning | ||
|
||
### Auto minor versioning | ||
|
||
The [Publish GitHub Actions workflow](./.github/workflows/publish.yml) auto versions a Pull Requests code with a `minor` | ||
version once it has been merged into the `main` branch. | ||
All you have to do is commit your code and raise a Pull Request and the pipeline will auto version your code for you. | ||
|
||
### Major or Patch versioning | ||
|
||
If you wish to `patch` or `major` version your codebase use: | ||
Override the following config items: | ||
|
||
```bash | ||
$ npm version <patch|major> | ||
export AZURE_CLIENT_SECRET=test_value | ||
export OAUTH_AUTH_URL=http://127.0.0.1:5557/oidc/authorize | ||
export OAUTH_TOKEN_URL=http://127.0.0.1:5557/oidc/token | ||
``` | ||
|
||
Then: | ||
|
||
- Push this code with the auto generated commit to your GitHub Repository | ||
- Raise a Pull Request | ||
- Merge your code into the `main` branch | ||
- The [Publish GitHub Actions workflow](./.github/workflows/publish.yml) will tag and push your `major` or `patch` | ||
version tags to your GitHub Repository | ||
- The [Publish GitHub Actions workflow](./.github/workflows/publish.yml) will release your `major` or `patch` | ||
versioned code | ||
|
||
## Docker | ||
|
||
### Development image | ||
|
||
Build: | ||
|
||
```bash | ||
$ docker build --target development --no-cache --tag cdp-portal-stubs:development . | ||
``` | ||
|
||
Run: | ||
|
||
```bash | ||
$ docker run -e GITHUB_API_TOKEN -p 3008:3008 cdp-portal-stubs:development | ||
``` | ||
|
||
### Production image | ||
|
||
Build: | ||
|
||
```bash | ||
docker build --no-cache --tag cdp-portal-stubs . | ||
``` | ||
|
||
Run: | ||
|
||
```bash | ||
$ docker run -e GITHUB_API_TOKEN -p 3001:3001 cdp-portal-stubs | ||
``` | ||
## What it currently provides | ||
|
||
## Licence | ||
Mock calls for github apis: | ||
|
||
THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at: | ||
- Get/Set repo content | ||
- Raise a PR | ||
- Get Commit history | ||
- Get repo data | ||
- Trigger workflow | ||
- Various graphql queries for enabling automerge and listing team data | ||
|
||
<http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3> | ||
Raising a PR will also result in a github webhook message being posted to the githubEvents queue, and in some cases a workflow complete message. | ||
Creating a new repository results in a workflow run complete message. | ||
|
||
The following attribution statement MUST be cited in your products and applications when using this information. | ||
Mocks calls to an ECR repository | ||
|
||
> Contains public sector information licensed under the Open Government license v3 | ||
- Lists available repositories | ||
- Gets manifest | ||
- Gets minimal layers | ||
|
||
### About the licence | ||
An admin endpoint is provided to simulate a new image being pushed `POST /_admin/trigger-ecr-push/{repo}/{tag}` | ||
|
||
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. | ||
## Test Data | ||
|
||
It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions. | ||
The base set of services is held in /config/services.js. Adding or removing services to this list will result in them being returned in the mock API calls. |
Oops, something went wrong.