Skip to content

Commit

Permalink
Merge pull request #6 from cabinetoffice/NTRNL-303-add-dev-config
Browse files Browse the repository at this point in the history
Ntrnl 303 add dev config
  • Loading branch information
harley-harris authored Jan 18, 2024
2 parents 1725800 + 54542e5 commit 808171f
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ BASE_URL="http://localhost:3000"
CDN_HOST="d6nh3dxv55e16.cloudfront.net"
NODE_SSL_ENABLED="false"

LOG_LEVEL = info
HUMAN = true
LOG_LEVEL=info
HUMAN=true
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

The GitHub request application is a tool designed to streamline and automate the process of managing and tracking request for GitHub. This includes the adding, removal or editing of members.

Each page or user interface, defined by an endpoint, is devided into three components (MVC) and as a best practice the names for the model, view and controller have, when possible, the same start name of the endpoints (es. for the `/info` page we have the: `info.controller.ts` and `info.html` files if model present we will have had `info.model.ts`)
Each page or user interface, defined by an endpoint, is devided into three components (MVC) and as a best practice the names for the model, view and controller have, when possible, the same start name of the endpoints (e.g. for the `/info` page we have the: `info.controller.ts` and `info.html` files if models are present we would have `info.model.ts`)

### The View

Expand All @@ -22,7 +22,7 @@ Directory Path | Description
--- | ---
`./.github` | Github folder, includes `PULL_REQUEST_TEMPLATE.md` on how to make a pull request to the project and `dependabot.yml` configuration options for dependency updates.
`./.husky` | Add pre check script, includes `pre-commit` and `pre-push` checks
`./src` | Contains all typescripts code
`./src` | Contains all Typescript code
`./src/app.ts` | Application entry point
`./src/bin/www.ts` | Server configuration
`./src/config/index.ts` | Contains all the application's configurations
Expand All @@ -31,7 +31,7 @@ Directory Path | Description
`./src/model` | OE Session and View Data Model
`./src/routes` | Paths and routes controller (Only GET and POST enabled)
`./src/service` | Interface to the API through SDK
`./src/utils` | Facade for CH services (logging and session) and other application utils (navigation, application data ...)
`./src/utils` | Facade for CO services (e.g. logging) and other application utils (navigation, application data ...)
`./src/validation` | Sets of express validator middlewares for each page
`./test` | Jest Test files (`*.spec.ts`, `setup.ts`, and `*.mocks.ts`)
`./view` | Contains all the html nunjucks structure files
Expand All @@ -44,10 +44,18 @@ We use ESlint as both a formatter and code quality assurance. Eslint can also be

1. Install the [ESlint VScode extenstion](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).
2. Open your user settings (JSON) inside VScode and add the following:
```
"editor.formatOnSave": true,
"editor.codeActionsOnSave": { "source.fixAll.eslint": true }
```

3. Reload VScode.

## Running local development environment with Docker

Docker is used run the application in development mode, with tooling setup to detect changes in local `src` directory and reload the container's node server.

Follow the steps in [Launching-the-web-app](#Launching-the-web-app), and ensure that `NODE_ENV=development` is set in the `.env` file.

## Launching the web-app

Expand All @@ -59,15 +67,14 @@ We use ESlint as both a formatter and code quality assurance. Eslint can also be

### Building the Docker Image

1. Create a copy of the .env.example file and name it .env:
1. Create a copy of the ``.env.example`` file and name it `.env`:

Then to run:
Then run:

make docker-build

make docker-up

This will then download the necessary dependencies, build the Docker image, and start the application.
You will be able to access it on [Localhost:3000](localhost:3000).

You will be able to access it on [localhost:3000](localhost:3000).

2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ services:
dockerfile: ./infrastructure/docker/${NODE_ENV}/Dockerfile
ports:
- "${PORT}:3000"
volumes:
- ./:/app
environment:
- NODE_ENV=${NODE_ENV}
- PATH_SSL_PRIVATE_KEY=${PATH_SSL_PRIVATE_KEY}
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/docker/development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ WORKDIR /app
COPY . .
RUN npm ci --silent && npm run build

CMD ["npm", "start"]
CMD ["npm", "run", "start:dev"]
7 changes: 7 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"exec": "ts-node ./src/server.ts",
"ext": "ts,html",
"watch": [
"./src"
]
}
Loading

0 comments on commit 808171f

Please sign in to comment.