Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"getaddrinfo ENOTFOUND" error #6

Open
tyleri opened this issue Jan 7, 2017 · 15 comments
Open

"getaddrinfo ENOTFOUND" error #6

tyleri opened this issue Jan 7, 2017 · 15 comments

Comments

@tyleri
Copy link

tyleri commented Jan 7, 2017

I recently came across this issue when using request-promise-native. When sending a GET or POST request to certain URLs, I received a "getaddrinfo ENOTFOUND" error. This seems to happen randomly (i.e. some URL requests would throw this error during one run but work completely fine on the next). After some Googling, I found this issue:

nodejs/node#5436 (comment)

Although I didn't find this documented in the request-promise page, I added {"family": 4} to the options, and I stopped getting the error. It might be useful to either set "family" to 4 by default or just make a note of this in the documentation.

@analog-nico
Copy link
Member

Thank you @tyleri , this is an immensely useful tweak!

I wouldn't set this option by default because of the unwanted effects it may cause for existing request-promise / request-promise-native users. However, I'll add this to the docs. Maybe a "troubleshooting" section would make sense.

I'll keep this issue open until I updated the docs.

@olexme
Copy link

olexme commented Jan 17, 2017

I have similar issue. I get the err like below (theurl.com is a placeholder) after a few hours of request-promise package usage and hundreds of requests pointing the same 'theurl.com' url. Not sure if it is caused by temporary DNS issue but at some point the package starts throwing errors like below. At that time 'dig theurl.com' resolves url properly, but the lib got stuck after first err and the only option is to restart the node, which helps. I will try to add static url to /etc/hosts first then I will check that {"family": 4} option.

Some details:
System: os X sierra
Node: v5.10.1
request-promise v4.1.1
Request options:
{
 followRedirect: false,

uri: “https://theurl.com/apath”,

qs: {
 goto: “https://ok.path.com”,

gotoOnFail: “https://fail.path.com”,
 },

json: true 
}

Error:
{ [RequestError: Error: getaddrinfo ENOTFOUND theurl.com theurl.com:443]
name: 'RequestError',
message: 'Error: getaddrinfo ENOTFOUND theurl.com theurl.com:443',
cause:
{ [Error: getaddrinfo ENOTFOUND theurl.com theurl.com:443]
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'theurl.com',
host: 'theurl.com',
port: 443 },

@analog-nico
Copy link
Member

Hi @olexme , the issue you are facing is very low level. request-promise uses request and request uses node's core libraries. The error is thrown by the core libraries. { family: 4 } may help but in your case – since you are requesting the same server over and over again – you may also look into DNS caching. Read the full discussion in this issue to get a good understanding. Finally, since it is a node-level issue you may update to the latest LTS.

@kilianc
Copy link

kilianc commented Feb 26, 2017

@tyleri like this?

require('request-promise-native').defaults({ family: 4 })

@tyleri
Copy link
Author

tyleri commented Feb 26, 2017

@kilianc
I didn't do it that way, but that might work.
I just followed the example here, but added "family: 4" to the options:
https://www.npmjs.com/package/request-promise#post-data-to-a-json-rest-api

@kilianc
Copy link

kilianc commented Feb 26, 2017

I couldn't find any reference in the request source code to a family property. I will give this a try, thanks @tyleri

@tyleri
Copy link
Author

tyleri commented Feb 26, 2017

Yes, as mentioned above, it is not documented in request-promise. It seems to be a property of the underlying Node.js libraries that request-promise uses.

@kilianc
Copy link

kilianc commented Feb 27, 2017

@tyleri so it's a pass through property that's why I couldn't find it.

ONS-Tom added a commit to ONSdigital/business-index-ui that referenced this issue Oct 26, 2017
ONS-Tom added a commit to ONSdigital/business-index-ui that referenced this issue Nov 10, 2017
* Fix server routes tests

* Fix Gitlab URL in Jenkinsfile

- Fix replacement URLs for Sed for API Gateway

* Fix Gitlab config to use correct branch

* Fix Gitlab credentialsId

* Remove POST body from 'prod' code

* Add testing code for using ENV variables

* Add debugging statements to node server

- For debugging in CF

* Change gitlab credentials back to bi

* Add json:true to node server request

* Add family:4 to request options in node server

- request/request-promise-native#6

* Remove hardcoded basicAuth values

* Fix search enpoint config

* Fix formQuery config, no need for & in query

* Remove debugging statements, console logs etc.

* Add logging config from sbr-ui

- Add filename to logs
- Use proper morgan logging with Winston logger

* Update Jenkinsfile with new configuration

- Build node 'GMU' label

* Add code for ShowConfetti, in server + frontend (#7)

- Copy showConfetti code from sbr-ui
awharris pushed a commit to ONSdigital/business-index-ui that referenced this issue Jul 19, 2018
* Feature/skeleton (#1)

* Add skeleton bi-ui frontend, mostly a clone of sbr-ui

- Cloned sbr-ui, replaced all sbr related code to bi, apart from apiActions

* Change apiActions to match business index format

* Add prototype UBRN search

* Add working UBRN search using react-table

* Add in pagination prop for UBRN results table

* Feature/range match search (#2)

* Fix validation for UBRN search

- Add config file for valid refs

* Add ONS inputs for Match search, used SDC styles

- Used Less to isolate SDC styles, prefix with 'sdc-isolation' to prevent conflicts with other styles

* Add inputs for Match search

- Add bands to utils/convertBands.js

* Add code for working Match search

- Uses all inputs

* Fix reload of Match data

- When going from match -> Home or another page, the data will be reloaded into the search inputs when you go back
- Turn off eslint rule

* Fix issue with clearing of Select boxes

* Remove UPRN field from Match page

* Add react-select input with working aria-hidden

- Use 'hacky' bit of js to fix buggy react-select component, on any update, look for classNames within react-select with an aria-hidden tag and change them
- Add filterable toggle (checkbox) to match search

* Refactor MatchForm, use seperate Components

- Move TextInput and SelectInput to seperate files
- Fix PropTypes

* Add scroll to results on search for Match

* Fix scroll to bottom on search feature

* Fix focus on first input after resetting the form

* Add minor fixes to UBRN page, naming etc.

* Fix naming of SearchRefForm -> UBRNForm

* Use CheckBoxInput component in Match

* Add fixed code for RangeSearch query

* Fix persistance of multiple select input values

* Fix bug for Clear button not clearing all the data

* Move SelectMultipleInput code to seperate file

* Add TextInputInline component for dual inputs

- i.e. for min/max inputs

* Fix use of filter props in RangeForm

* Add working RangeQuery search

- Add new formatter method in utils/formQuery.js
- Add (currently unused) consts in ApiConstants
- Fix apiAction for RangeQuery

* Fix formatRangeQuery, remove debugging statements

* Fix showFilter bug, shows after new search

* Transform businessName to upper case

* Add encodeSpecialChars method to formQuery

- For encoding businessName
- Copied method from business-index-ui

* Fix/initial refactor (#4)

* Add table of contents and description to README

* Fix README table of contents

* Add fix for redux reset store JSON issue

- See #3 for more details

* Add example expand view to Match

* Remove init query code to '' rather than {}

- This was causing bugs on refresh

* Fix/authentication (#5)

* Add mock API Gateway related code

- Copy from sbr-ui fix/authentication

* Migrate sbr-ui fix/authentication code to bi-ui

- Remove unused dependancies (jwt)
- Fix LoginActions/auth.js to mimick sbr-ui
- Add base64 encoding to LoginActions
- Use base64 for encoding username:password rather than bcrypt in the mock gateway
- Fix saving of accessToken in sessionStorage

* Fix rerouting of API requests to work for bi

- Change URL to localhost:9000 (business-index-api)

* Fix/deployment (#6)

* Fix server routes tests

* Fix Gitlab URL in Jenkinsfile

- Fix replacement URLs for Sed for API Gateway

* Fix Gitlab config to use correct branch

* Fix Gitlab credentialsId

* Remove POST body from 'prod' code

* Add testing code for using ENV variables

* Add debugging statements to node server

- For debugging in CF

* Change gitlab credentials back to bi

* Add json:true to node server request

* Add family:4 to request options in node server

- request/request-promise-native#6

* Remove hardcoded basicAuth values

* Fix search enpoint config

* Fix formQuery config, no need for & in query

* Remove debugging statements, console logs etc.

* Add logging config from sbr-ui

- Add filename to logs
- Use proper morgan logging with Winston logger

* Update Jenkinsfile with new configuration

- Build node 'GMU' label

* Add code for ShowConfetti, in server + frontend (#7)

- Copy showConfetti code from sbr-ui

* Fix/user feedback (#8)

* Add fix for PostCode on Match form

- Add value prop

* Add SummaryTable component for useful stats

- For num results + capped results

* Add ChildRefTable component for child references

- Not using Redux, just using fetch() inside the component

* Add siccodes conversion JSON

- Add SIC code conversion to expand view

* Add ResultsTable component

* Add additional props into ResultsTable

- DefaultPageSize, pagination etc.

* Fix clear functionality for UBRN search

- Focus on UBRN input after clear

* Remove comments, add config for /business endpoint

* Add proper formatting of ExpandView JSON

* Add Business Index description on Home page

* Fix Logout logic, handle 500's

- If there is a server error whilst logging out, the user will still be logged out

* Clear sessionStorage rather than localStorage

* Fix/console warnings (#9)

* Remove unused scripts from index.html

- Remove ONS JS & Jquery

* Fix key error in SummaryTable

* Fix role in reducer and node server

- Add 'role' back into login reducer
- Fix role returns in utils/auth.js
- Add role return into checkToken route in the node server

* Fix console warnings

- Unused imports etc.

* Fix propTypes errors

- Mostly related to the value prop

* Fix propType errors for ShowConfetti

* Add fix for IndustryCode inputs

- Use encoded square brackets

* Add fixes for industry code & refs bugs

- Fix use of industry code conversion
- Fix max number of refs not showing (bug in reduce function)

* Fix/cn expand view (#10)

* Add fix for CN display in helperMethods

* Remove debugging statement

* Feature/convert bands (#11)

* Add *bands conversion to ResultsTable

- Show the actual value rather than 'A' or '1' etc.

* Add checkBox for convertBands onto Match/Range

- Can toggle whether or not to use convertBands in the ResultsTable

* Fix passing of props to RangeForm

* Fix checkBoxes to be inline

- Use SDC grid

* Feature/export to csv (#12)

* Add export to csv functionality

- Using utils/export
- Copied from the business-index-ui

* Add config/export with name of CSV

* Add export to JSON button to ResultsTable

* Feature/ch link (#13)

* Add ch link in child refs table

* Add security fix for target="_blank"

* Fix/env vars (#14)

* Add new Jenkinsfile

* Update react-scripts so env vars can be used

- Update to 0.2.3 so we can use environment variables

* Use env vars for URLS in the frontend

* Add server environment variables

* Add updated Jenkinsfile

* Add debugging statements

* Remove debugging statements, fix Jenkinsfile

* Remove unused manifest.yml

* Fix/node server refactor (#15)

* Add refactored node server with seperate routes

- Move routes to /routes/...
- Do node config in index.js
- Use proper session management

* Refactor react code to integrate with new server

- For checkToken, put the token in an Authorization header

* Remove npm-run-script from package.json

* Fix README to include new running details

* Remove use of npm run script from Jenkinsfile

* Change server test config

- When you run npm run test-server, it will run the test that builds the project first, before running the other tests recursively in /server-test-spec

* Use test:type rathe than test-type

* Fix server tests, use seperate files

- The test:server runs the server.test.js first, which tests the npm run build command and the serving of static assets, the api/auth functionality are then tested, by recursively testing all files in /test/server-test-spec/*

* Remove unused component tests, unused dependancies

- Remove unused component tests + package.json test script
- Refactor dependancies in package.json, move test ones to devDeps

* Change order of routes import in node server

- Fix /version

* Fix static files path

- Fix start command in package.json

* Fix/jenkinsfile branch name (#16)

* Add fixed Jenkinsfile, fix branch names

* Change Gitlab branch to develop

* Fix/error handling 404 (#17)

* Add fix for 404 no results error

* Fix display of error message

- use () => method so closeModal isn't called every render

* Refactor scroll to top feature, reduce duplication

* Fix errorModal on Login form

* Add fix for range search

- Use proper encoded [ and ]

* Fix npm cover script, use correct server test

* Feature/redis sessions (#18)

* Add redis sessions to /sessions

- Remove component testing section on README
- Add redis-sessions dependancy
- Change /helpers to /utilities

* Add more to the README description

* Feature/search hoc (#19)

* Remove unused results key in Match/Range

- Remove commented out method in UBRNLookup

* Add Search Higher Order Component

- This makes the individual search pages (Match/Range/UBRN) redundant, as those pages use almost identical functionality, we can move all the common logic (all of it) into a higher order component, which returns a component based upon the input settings
- Modify UBRN redux action to handle commonality between match + range

* Move search pages config into /config/search

* Add comment into SearchHOC, explain use of HOC

* Fix console warning, unused var

* Add convert bands checkbox into UBRNForm

* Fix showFIlter, set false for UBRNForm

* Add fix for buggy showFilter

* Fix/search view grids (#20)

* Add refactored grid for UBRN & Range forms

- Use sdc grid to fit more inputs on the screen and handle smaller screen sizes

* Refactor MatchForm grid, condense inputs

* Remove unused grid helper div from Range grid

* Remove unused grid div from UBRNForm

* Remove unused BreadCrumb component

- Using the pattern library instead

* Remove unused DeveloperView component

* Remove unused CSS + JS

- Mostly bootstrap related

* Feature/highlight business name (#21)

* Add highlighting of businessName to ResultsTable

- Add prop businessName to be passed in to ResultsTable
- Add highlighting of businessName, using a <span> with a background colour

* Add try catch for creating the Regex

* Fix businessName prop to only update on a search

- Rather than the highlighting live updating as the user types, it will just do the highlighting when the search button is pressed

* Fix bug where highlighting is removed

- When changing between Match/Range/UBRN, the highlighting would dissapear

* Fix/results table key error (#22)

* Add reformatted ResultsTable code

- Add spacing to a large line of code to increase readability

* Add fix for key error in ResultsTable

- If there are multiple matches for the highlight method, a key error would occur due to duplicate keys, fix this by using an index counter as part of the key
- An ESLint key rule had to be disabled, however as the UBRN is used as part of the key it shouldn't be an issue

* Feature/health route (#23)

* Add /api/health route to the node server

- Just returns 'OK' for now

* Add extra details to comment on new route

* Add health check step to Jenkinsfile

* Change /api/health route to return JSON not text

* Add assignment of curl response status to variable

* Add build fail trigger to Check Health stage

* Fix/redux refactor (#24)

* Remove unused redux code

- Remove unused setPeriod action, SET_PERIOD constant and reducer code
- Remove large comments stating basic redux patterns
- Remove config files for periods

* Refactor setResults/Headers to not use JSON

- Just set the actual variable rather than nexting in JSON

* Refactor redux actions to be more concise

- Rather than defining an action for each type of search, use one action but pass in an additional value, in our case, the json key of a redux store item, so SET_QUERY with 'match' or 'range'

* Remove obvious redux related comments

- Don't need to explain what a reducer is etc.

* Remove verbose comments in redux actions

- Don't need to explain what an action is

* Remove unused error message related redux code

- Just the top level error message json key in the store, not the nested error messages in ubrn/match/range

* Remove unused timestamp from error message

* Refactor ApiAction to use generic action creator

- Rather than using UBRN/Match/Range actions, just use one generic action creator called search which will work for all search types
- Remove unused api searches in /utils/apiSearch

* Fix/utils unit tests (#25)

* Add convertBands unit tests

* Remove unused helper method (already in convert bands)

* Remove unused helperMethods

* Add helper methods unit test

* Remove flow annotations from /utils

- Not needed for such a small codebase, parameter types will be documented in JSDoc style doc strings

* Remove flow related configuration

- Remove dependancy from package.json
- Remove flow config file, .flowconfig

* Remove flow details in CONTRIBUTING.md

* Add unit test for Sic code conversion

* Fix/jenkinsfile manifest (#26)

* Add fix for using manifest based on branch name

* Remove promote to beta section of Jenkinsfile

* Update node + npm engines version in package.json

* Update Jenkinsfile to work with new CF

- Update deploy part of the script, new CF URL

* Remove unused API_GW_URL variable

* Fix Jenkinsfile to use actual Gitlab dir names

* Feature/dot env (#27)

* Add .env file for loading environment variables

- Add dotenv dependancy to package.json
- Update react-scripts to 0.5.1
- Remove env vars from package.json scripts (just start scripts)
- Move favicon and index.html to /public

* Remove env var section from README

- Fix mistake, change Bootstrap Isolation to SDC Isolation

* Update Jenkinsfile to handle .env config

* Update Jenkinsfile Gitlab branch

* Remove env vars from Jenkinsfile

- Use .env instead

* Use global Jenkins variable in place of local one

* Remove unused Jenkinsfile variables

* Fix tests to manually fork apiGateway script

* Add test user/pass env vars into test scripts

* Fix/ping health route (#28)

* Add --insecure flag to Jenkinsfile curl request

* Add documentation for new curl request flag

* Fix/export csv refactor (#29)

* Add refactored exportCSV method

* Refactor exportCSV code to improve readability

- Change name of config variable to be more intuitive

* Add documentation to methods in /utils/export.js

* Fix/api request refactor (#30)

* Remove unused onChange method from auth.js

* Add refactored fetch usage for searching

- Add accessAPI which is basically a helper to preset some commonly used config for fetch

* Add refactored InfoActions with new fetch

- Use accessAPI method in InfoActions

* Refactor login action to use accessAPI

* Add refactored logout LoginAction

* Add refactored logout action in LoginActions

* Remove unused /utils files

- Use default export in accessAPI.js

* Add more informative api request error messages

* Fix wrong last update usage in Info page

* Fix Jenkinsfile library branch

- Use master, not a deleted branch

* Feature/dockerfile (#31)

* Add Dockerfile and .dockerignore file

* Add env var to apiGateway config

- Use passed in env var for server url, so that we can pass in a docker url

* Remove misc notes from dockerfile

* Update README with better running instructions

* Update Jenkinsfile shared pipeline branch

* Fix/fetch promise refactor (#32)

* Add refactored fetch using promises

- Use promise rather than callback to make code more concise
- Leave in old accessAPI method until other *Actions are refactored

* Add refactore InfoActions using promises

- Fix bug where spinner would continue showing if an error had occured

* Fix bug relating to catching failed promises

* Remove old apiAccess method

- Refactor *Actions to use new accessAPI method

* Fix display of ErrorModal

- Convert to pure component
- Fix child ref table to use ApiAccess for API requests

* Feature/mock backend api (#33)

* Fix use of favicon in index.html

- Use properly formatted path

* Add fake request which mocks fetch

- All API requests pass the type of request (search/business/uiInfo etc) into accessAPI, so that URL's don't have to be parsed to find the endpoint
- Add /utils/request.js which will use the mocked fetch when it's in a test environment (REACT_APP_ENV)

* Make promise forming method more concise

* Move fakeFetch code into requestUtils

- Refactor code into small methods
- Fix ESLint error

* Add request dependancy to server package.json

* Remove unused bcrypt dependancy

* Reduce setTimeout when doing a fakeRequest

* Add .env file (remove from .gitignore)

* Fix/session classes (#34)

* Add proper use of OO inheritance in Sessions

- Each type of session extends the Session class
- Add documentation of Session methods
- Add pg dependancy to package.json

* Update Jenkinsfile Gitlab branch

* Fix PsqlSession pool creation bug

- Fix bug where just importing the PsqlSession class would trigger a new pool to be created, move this to an init method which is called from the constructor

* Remove unused CI.md README

* Feature/styles update (#35)

* Change REACT_APP_ENV value to 'test'

* Add assets for the new pattern library

- Add css to the /public directory
- Add logo image to /src/resources/img
- Remove old styles css import in index.js
- Update index.html to handle new CSS

* Remove unused dependancies, refactor ESLint

- Remove unused dependancies in package.json (react a11y)
- Remove unused eslint config section from package.json
- Add .vscode to .gitignore
- Remove unused routes

* Remove unused React components and utils

- Remove any unused views/components/helper methods
- Remove reducer/action/constant code relating to get ui/api info
- Remove unused config

* Fix ESLint issue with arrow functions

* Add updated Login page

- Add LoginAction for resetting the error message
- Add /patterns with Button/TextInput/LinkButton components
- Fix routes in routes file

* Refactor login page to use TextInput components

- Refactor TextInput to make it work with either refs or onChange

* Fix routing issue, refactor functional components

- Fix issue with SearchHOC (don't use it for now)

* Add Panel component for showing error/info/warn

* Add working search feature back in

- Add components to deal with the search (Business, ResultsList etc)
- Add redirect in ApiActions
- Fix exportJson method

* Fix industry code and multiple select inputs

* Remove unused files, refactor SearchHOC

- Remove unused assets
- Move onChange helpers to helperMethods for SearchHOC

* Fix issue with depracated replaceState params

* Fix documentation in all React classes

- Ensure documentation is consistent, e.g. no need to duplicate
prop details

* Refactor Redux related code, remove unused code

- Remove unused redux code (related to Match/range/ubrn)
- Move helper methods to /utils/helperMethods.js

* Fix documentation formatting

- Use consistent documentation format, where the parameters are only described where prop types isn't used

* Remove unused object.assign dependancy

* Remove verbose testing details from the README

* Add Pagination component and connect to Results

* Fix issue with <table> child, use <tbody>

- https://stackoverflow.com/questions/41716528/react-tr-cannot-appear-as-a-child-of-td-see-comment-td-tr

* Add ChildRefList component of child refs

* Fix ESLint errors

* Fix forming of the ES query

- Fix form query to work for generic queries
- Change env var back to local

* Use immutable set state, no mutating of state

- Use ES6 way of setting state immutably

* Add fix for searching on child ref (VAT/CH/PAYE)

* Fix use of plural businesses on Results page

* FIx issue with errorModal not showing on Home/Results

* Export helper method to fix unit test

* Add ESLint jsx-a11y to package.json to fix tests

* Fix https and password type issue

* Add type=text to SearchForm text inputs

* Add fix for text input sizes

* Remove sdc-main css (unused)

* Feature/styles update tests (#36)

* Add unit test for exportCSV method

* Add unit tests for formQuery

* Fix method and add test for formatData

* Add unit tests for other helperMethods code

* Fix/refs search (#37)

* Add fix for refs searching, add new fields

- Add new fields for CRN, VAT, PAYE search on SearchForm

* Remove unused code in formQuery.js

* Remove load test part of Jenkinsfile

* Add stress tests back in, fix unit test

* Add new unit tests for new formQuery inputs

* Fix/react 16 migration (#38)

* Add start of React 15 -> 15 migration

- Remove use of halogen for loading spinner, use fork which is compatible with react 16
- Upgrade react-router dependancy

* Fix use of React 16 for searching

- Fixed all features apart from 404 page and use of react-modal-dialog

* Fix 404 page display

* Refactor SearchForm to be functional component

* Change SearchForm to use props, no deconstruct

* Refactor code base to use Panel, not a modal

- Remove react-modal-dialog from package.json (not compatible with React 16 + we shouldn't be using it anyway)
- Refactor all uses of ErrorMessage to use a Panel instead
- Add props to Panel so that a close link can be used

* Feature/child refs hoc (#39)

* Refactor fetching of child refs into HOC

- ChildRefList/Table both have almost identical code for fetching /business/:id, so the common logic has been moved into a higher order component

* Add working use of HOC in ChildRefTable

* Fix/error modal bug (#40)

* Add fix for ChildRefList, use props not this.state

* Add fix for ChildRefTable, use props not state

* Fix/styles feedback fix (#43)

* Fix Button to use dynamic style/class props

- For the clear button, use secondary button type with border

* Remove username from Header.js

* Fix use of show references icons

- Add /img to /public
- Add chevron image to /src/resources

* Add capped badge if the results are capped

- Results cap at 10,000

* Add updated CSS for new search bar

* Seperate out SearchForm into different components

- Change props for button/textInput

* Add seperate search form for the home page

- Fix issue with TextInputInline not displaying the correct size

* Add fix for width of react-table (12 cols now)

* Fix column widths, fix issue with htmlFor in range input

* Fix more col widths, remove scroll in ResultsList

* Remove spacing from Home search inputs

* Fix spelling errors

- CN -> CRN
- Use 'Employment' instead of 'Employment Bands' in react table

* Add scroll to results feature

* Change scroll to go to Search header

* Feature/results capped at (#44)

* Add return of 'x-total-count' header

* Add display of panel showing number of results capped

- Add reducer/apiActions for setting capped results number
- Add allowed cors headers in the server for X-Total-Count
- Add return of X-Total-Count in apiGateway and api.js
- Modify accessApi.js to handle getting the headers

* Add unit test for new helperMethod

* Fix/mock fetch headers (#45)

* Add fix for mock fetch change of format

- From accessAPI we get a promise back with the response rather than a promise for the json

* Add better explanation of fetch issue

* Fix/export convert bands (#46)

* Add redux related code for exporting csv or json

* Add conversion of bands in csv/json download

* Use redux for the export of csv/json

* Add tests for export.js util

* Fix ESLint error (define before use)

* Fix/json fields update (#47)

* Fix JSON field accessor names

* Fix JSON fields in export.js

* Fix JSON fields for fake fetch functionality

* Fix tests with new JSON keys
awharris pushed a commit to ONSdigital/business-index-ui that referenced this issue Sep 21, 2018
* Feature/skeleton (#1)

* Add skeleton bi-ui frontend, mostly a clone of sbr-ui

- Cloned sbr-ui, replaced all sbr related code to bi, apart from apiActions

* Change apiActions to match business index format

* Add prototype UBRN search

* Add working UBRN search using react-table

* Add in pagination prop for UBRN results table

* Feature/range match search (#2)

* Fix validation for UBRN search

- Add config file for valid refs

* Add ONS inputs for Match search, used SDC styles

- Used Less to isolate SDC styles, prefix with 'sdc-isolation' to prevent conflicts with other styles

* Add inputs for Match search

- Add bands to utils/convertBands.js

* Add code for working Match search

- Uses all inputs

* Fix reload of Match data

- When going from match -> Home or another page, the data will be reloaded into the search inputs when you go back
- Turn off eslint rule

* Fix issue with clearing of Select boxes

* Remove UPRN field from Match page

* Add react-select input with working aria-hidden

- Use 'hacky' bit of js to fix buggy react-select component, on any update, look for classNames within react-select with an aria-hidden tag and change them
- Add filterable toggle (checkbox) to match search

* Refactor MatchForm, use seperate Components

- Move TextInput and SelectInput to seperate files
- Fix PropTypes

* Add scroll to results on search for Match

* Fix scroll to bottom on search feature

* Fix focus on first input after resetting the form

* Add minor fixes to UBRN page, naming etc.

* Fix naming of SearchRefForm -> UBRNForm

* Use CheckBoxInput component in Match

* Add fixed code for RangeSearch query

* Fix persistance of multiple select input values

* Fix bug for Clear button not clearing all the data

* Move SelectMultipleInput code to seperate file

* Add TextInputInline component for dual inputs

- i.e. for min/max inputs

* Fix use of filter props in RangeForm

* Add working RangeQuery search

- Add new formatter method in utils/formQuery.js
- Add (currently unused) consts in ApiConstants
- Fix apiAction for RangeQuery

* Fix formatRangeQuery, remove debugging statements

* Fix showFilter bug, shows after new search

* Transform businessName to upper case

* Add encodeSpecialChars method to formQuery

- For encoding businessName
- Copied method from business-index-ui

* Fix/initial refactor (#4)

* Add table of contents and description to README

* Fix README table of contents

* Add fix for redux reset store JSON issue

- See #3 for more details

* Add example expand view to Match

* Remove init query code to '' rather than {}

- This was causing bugs on refresh

* Fix/authentication (#5)

* Add mock API Gateway related code

- Copy from sbr-ui fix/authentication

* Migrate sbr-ui fix/authentication code to bi-ui

- Remove unused dependancies (jwt)
- Fix LoginActions/auth.js to mimick sbr-ui
- Add base64 encoding to LoginActions
- Use base64 for encoding username:password rather than bcrypt in the mock gateway
- Fix saving of accessToken in sessionStorage

* Fix rerouting of API requests to work for bi

- Change URL to localhost:9000 (business-index-api)

* Fix/deployment (#6)

* Fix server routes tests

* Fix Gitlab URL in Jenkinsfile

- Fix replacement URLs for Sed for API Gateway

* Fix Gitlab config to use correct branch

* Fix Gitlab credentialsId

* Remove POST body from 'prod' code

* Add testing code for using ENV variables

* Add debugging statements to node server

- For debugging in CF

* Change gitlab credentials back to bi

* Add json:true to node server request

* Add family:4 to request options in node server

- request/request-promise-native#6

* Remove hardcoded basicAuth values

* Fix search enpoint config

* Fix formQuery config, no need for & in query

* Remove debugging statements, console logs etc.

* Add logging config from sbr-ui

- Add filename to logs
- Use proper morgan logging with Winston logger

* Update Jenkinsfile with new configuration

- Build node 'GMU' label

* Add code for ShowConfetti, in server + frontend (#7)

- Copy showConfetti code from sbr-ui

* Fix/user feedback (#8)

* Add fix for PostCode on Match form

- Add value prop

* Add SummaryTable component for useful stats

- For num results + capped results

* Add ChildRefTable component for child references

- Not using Redux, just using fetch() inside the component

* Add siccodes conversion JSON

- Add SIC code conversion to expand view

* Add ResultsTable component

* Add additional props into ResultsTable

- DefaultPageSize, pagination etc.

* Fix clear functionality for UBRN search

- Focus on UBRN input after clear

* Remove comments, add config for /business endpoint

* Add proper formatting of ExpandView JSON

* Add Business Index description on Home page

* Fix Logout logic, handle 500's

- If there is a server error whilst logging out, the user will still be logged out

* Clear sessionStorage rather than localStorage

* Fix/console warnings (#9)

* Remove unused scripts from index.html

- Remove ONS JS & Jquery

* Fix key error in SummaryTable

* Fix role in reducer and node server

- Add 'role' back into login reducer
- Fix role returns in utils/auth.js
- Add role return into checkToken route in the node server

* Fix console warnings

- Unused imports etc.

* Fix propTypes errors

- Mostly related to the value prop

* Fix propType errors for ShowConfetti

* Add fix for IndustryCode inputs

- Use encoded square brackets

* Add fixes for industry code & refs bugs

- Fix use of industry code conversion
- Fix max number of refs not showing (bug in reduce function)

* Fix/cn expand view (#10)

* Add fix for CN display in helperMethods

* Remove debugging statement

* Feature/convert bands (#11)

* Add *bands conversion to ResultsTable

- Show the actual value rather than 'A' or '1' etc.

* Add checkBox for convertBands onto Match/Range

- Can toggle whether or not to use convertBands in the ResultsTable

* Fix passing of props to RangeForm

* Fix checkBoxes to be inline

- Use SDC grid

* Feature/export to csv (#12)

* Add export to csv functionality

- Using utils/export
- Copied from the business-index-ui

* Add config/export with name of CSV

* Add export to JSON button to ResultsTable

* Feature/ch link (#13)

* Add ch link in child refs table

* Add security fix for target="_blank"

* Fix/env vars (#14)

* Add new Jenkinsfile

* Update react-scripts so env vars can be used

- Update to 0.2.3 so we can use environment variables

* Use env vars for URLS in the frontend

* Add server environment variables

* Add updated Jenkinsfile

* Add debugging statements

* Remove debugging statements, fix Jenkinsfile

* Remove unused manifest.yml

* Fix/node server refactor (#15)

* Add refactored node server with seperate routes

- Move routes to /routes/...
- Do node config in index.js
- Use proper session management

* Refactor react code to integrate with new server

- For checkToken, put the token in an Authorization header

* Remove npm-run-script from package.json

* Fix README to include new running details

* Remove use of npm run script from Jenkinsfile

* Change server test config

- When you run npm run test-server, it will run the test that builds the project first, before running the other tests recursively in /server-test-spec

* Use test:type rathe than test-type

* Fix server tests, use seperate files

- The test:server runs the server.test.js first, which tests the npm run build command and the serving of static assets, the api/auth functionality are then tested, by recursively testing all files in /test/server-test-spec/*

* Remove unused component tests, unused dependancies

- Remove unused component tests + package.json test script
- Refactor dependancies in package.json, move test ones to devDeps

* Change order of routes import in node server

- Fix /version

* Fix static files path

- Fix start command in package.json

* Fix/jenkinsfile branch name (#16)

* Add fixed Jenkinsfile, fix branch names

* Change Gitlab branch to develop

* Fix/error handling 404 (#17)

* Add fix for 404 no results error

* Fix display of error message

- use () => method so closeModal isn't called every render

* Refactor scroll to top feature, reduce duplication

* Fix errorModal on Login form

* Add fix for range search

- Use proper encoded [ and ]

* Fix npm cover script, use correct server test

* Feature/redis sessions (#18)

* Add redis sessions to /sessions

- Remove component testing section on README
- Add redis-sessions dependancy
- Change /helpers to /utilities

* Add more to the README description

* Feature/search hoc (#19)

* Remove unused results key in Match/Range

- Remove commented out method in UBRNLookup

* Add Search Higher Order Component

- This makes the individual search pages (Match/Range/UBRN) redundant, as those pages use almost identical functionality, we can move all the common logic (all of it) into a higher order component, which returns a component based upon the input settings
- Modify UBRN redux action to handle commonality between match + range

* Move search pages config into /config/search

* Add comment into SearchHOC, explain use of HOC

* Fix console warning, unused var

* Add convert bands checkbox into UBRNForm

* Fix showFIlter, set false for UBRNForm

* Add fix for buggy showFilter

* Fix/search view grids (#20)

* Add refactored grid for UBRN & Range forms

- Use sdc grid to fit more inputs on the screen and handle smaller screen sizes

* Refactor MatchForm grid, condense inputs

* Remove unused grid helper div from Range grid

* Remove unused grid div from UBRNForm

* Remove unused BreadCrumb component

- Using the pattern library instead

* Remove unused DeveloperView component

* Remove unused CSS + JS

- Mostly bootstrap related

* Feature/highlight business name (#21)

* Add highlighting of businessName to ResultsTable

- Add prop businessName to be passed in to ResultsTable
- Add highlighting of businessName, using a <span> with a background colour

* Add try catch for creating the Regex

* Fix businessName prop to only update on a search

- Rather than the highlighting live updating as the user types, it will just do the highlighting when the search button is pressed

* Fix bug where highlighting is removed

- When changing between Match/Range/UBRN, the highlighting would dissapear

* Fix/results table key error (#22)

* Add reformatted ResultsTable code

- Add spacing to a large line of code to increase readability

* Add fix for key error in ResultsTable

- If there are multiple matches for the highlight method, a key error would occur due to duplicate keys, fix this by using an index counter as part of the key
- An ESLint key rule had to be disabled, however as the UBRN is used as part of the key it shouldn't be an issue

* Feature/health route (#23)

* Add /api/health route to the node server

- Just returns 'OK' for now

* Add extra details to comment on new route

* Add health check step to Jenkinsfile

* Change /api/health route to return JSON not text

* Add assignment of curl response status to variable

* Add build fail trigger to Check Health stage

* Fix/redux refactor (#24)

* Remove unused redux code

- Remove unused setPeriod action, SET_PERIOD constant and reducer code
- Remove large comments stating basic redux patterns
- Remove config files for periods

* Refactor setResults/Headers to not use JSON

- Just set the actual variable rather than nexting in JSON

* Refactor redux actions to be more concise

- Rather than defining an action for each type of search, use one action but pass in an additional value, in our case, the json key of a redux store item, so SET_QUERY with 'match' or 'range'

* Remove obvious redux related comments

- Don't need to explain what a reducer is etc.

* Remove verbose comments in redux actions

- Don't need to explain what an action is

* Remove unused error message related redux code

- Just the top level error message json key in the store, not the nested error messages in ubrn/match/range

* Remove unused timestamp from error message

* Refactor ApiAction to use generic action creator

- Rather than using UBRN/Match/Range actions, just use one generic action creator called search which will work for all search types
- Remove unused api searches in /utils/apiSearch

* Fix/utils unit tests (#25)

* Add convertBands unit tests

* Remove unused helper method (already in convert bands)

* Remove unused helperMethods

* Add helper methods unit test

* Remove flow annotations from /utils

- Not needed for such a small codebase, parameter types will be documented in JSDoc style doc strings

* Remove flow related configuration

- Remove dependancy from package.json
- Remove flow config file, .flowconfig

* Remove flow details in CONTRIBUTING.md

* Add unit test for Sic code conversion

* Fix/jenkinsfile manifest (#26)

* Add fix for using manifest based on branch name

* Remove promote to beta section of Jenkinsfile

* Update node + npm engines version in package.json

* Update Jenkinsfile to work with new CF

- Update deploy part of the script, new CF URL

* Remove unused API_GW_URL variable

* Fix Jenkinsfile to use actual Gitlab dir names

* Feature/dot env (#27)

* Add .env file for loading environment variables

- Add dotenv dependancy to package.json
- Update react-scripts to 0.5.1
- Remove env vars from package.json scripts (just start scripts)
- Move favicon and index.html to /public

* Remove env var section from README

- Fix mistake, change Bootstrap Isolation to SDC Isolation

* Update Jenkinsfile to handle .env config

* Update Jenkinsfile Gitlab branch

* Remove env vars from Jenkinsfile

- Use .env instead

* Use global Jenkins variable in place of local one

* Remove unused Jenkinsfile variables

* Fix tests to manually fork apiGateway script

* Add test user/pass env vars into test scripts

* Fix/ping health route (#28)

* Add --insecure flag to Jenkinsfile curl request

* Add documentation for new curl request flag

* Fix/export csv refactor (#29)

* Add refactored exportCSV method

* Refactor exportCSV code to improve readability

- Change name of config variable to be more intuitive

* Add documentation to methods in /utils/export.js

* Fix/api request refactor (#30)

* Remove unused onChange method from auth.js

* Add refactored fetch usage for searching

- Add accessAPI which is basically a helper to preset some commonly used config for fetch

* Add refactored InfoActions with new fetch

- Use accessAPI method in InfoActions

* Refactor login action to use accessAPI

* Add refactored logout LoginAction

* Add refactored logout action in LoginActions

* Remove unused /utils files

- Use default export in accessAPI.js

* Add more informative api request error messages

* Fix wrong last update usage in Info page

* Fix Jenkinsfile library branch

- Use master, not a deleted branch

* Feature/dockerfile (#31)

* Add Dockerfile and .dockerignore file

* Add env var to apiGateway config

- Use passed in env var for server url, so that we can pass in a docker url

* Remove misc notes from dockerfile

* Update README with better running instructions

* Update Jenkinsfile shared pipeline branch

* Fix/fetch promise refactor (#32)

* Add refactored fetch using promises

- Use promise rather than callback to make code more concise
- Leave in old accessAPI method until other *Actions are refactored

* Add refactore InfoActions using promises

- Fix bug where spinner would continue showing if an error had occured

* Fix bug relating to catching failed promises

* Remove old apiAccess method

- Refactor *Actions to use new accessAPI method

* Fix display of ErrorModal

- Convert to pure component
- Fix child ref table to use ApiAccess for API requests

* Feature/mock backend api (#33)

* Fix use of favicon in index.html

- Use properly formatted path

* Add fake request which mocks fetch

- All API requests pass the type of request (search/business/uiInfo etc) into accessAPI, so that URL's don't have to be parsed to find the endpoint
- Add /utils/request.js which will use the mocked fetch when it's in a test environment (REACT_APP_ENV)

* Make promise forming method more concise

* Move fakeFetch code into requestUtils

- Refactor code into small methods
- Fix ESLint error

* Add request dependancy to server package.json

* Remove unused bcrypt dependancy

* Reduce setTimeout when doing a fakeRequest

* Add .env file (remove from .gitignore)

* Fix/session classes (#34)

* Add proper use of OO inheritance in Sessions

- Each type of session extends the Session class
- Add documentation of Session methods
- Add pg dependancy to package.json

* Update Jenkinsfile Gitlab branch

* Fix PsqlSession pool creation bug

- Fix bug where just importing the PsqlSession class would trigger a new pool to be created, move this to an init method which is called from the constructor

* Remove unused CI.md README

* Feature/styles update (#35)

* Change REACT_APP_ENV value to 'test'

* Add assets for the new pattern library

- Add css to the /public directory
- Add logo image to /src/resources/img
- Remove old styles css import in index.js
- Update index.html to handle new CSS

* Remove unused dependancies, refactor ESLint

- Remove unused dependancies in package.json (react a11y)
- Remove unused eslint config section from package.json
- Add .vscode to .gitignore
- Remove unused routes

* Remove unused React components and utils

- Remove any unused views/components/helper methods
- Remove reducer/action/constant code relating to get ui/api info
- Remove unused config

* Fix ESLint issue with arrow functions

* Add updated Login page

- Add LoginAction for resetting the error message
- Add /patterns with Button/TextInput/LinkButton components
- Fix routes in routes file

* Refactor login page to use TextInput components

- Refactor TextInput to make it work with either refs or onChange

* Fix routing issue, refactor functional components

- Fix issue with SearchHOC (don't use it for now)

* Add Panel component for showing error/info/warn

* Add working search feature back in

- Add components to deal with the search (Business, ResultsList etc)
- Add redirect in ApiActions
- Fix exportJson method

* Fix industry code and multiple select inputs

* Remove unused files, refactor SearchHOC

- Remove unused assets
- Move onChange helpers to helperMethods for SearchHOC

* Fix issue with depracated replaceState params

* Fix documentation in all React classes

- Ensure documentation is consistent, e.g. no need to duplicate
prop details

* Refactor Redux related code, remove unused code

- Remove unused redux code (related to Match/range/ubrn)
- Move helper methods to /utils/helperMethods.js

* Fix documentation formatting

- Use consistent documentation format, where the parameters are only described where prop types isn't used

* Remove unused object.assign dependancy

* Remove verbose testing details from the README

* Add Pagination component and connect to Results

* Fix issue with <table> child, use <tbody>

- https://stackoverflow.com/questions/41716528/react-tr-cannot-appear-as-a-child-of-td-see-comment-td-tr

* Add ChildRefList component of child refs

* Fix ESLint errors

* Fix forming of the ES query

- Fix form query to work for generic queries
- Change env var back to local

* Use immutable set state, no mutating of state

- Use ES6 way of setting state immutably

* Add fix for searching on child ref (VAT/CH/PAYE)

* Fix use of plural businesses on Results page

* FIx issue with errorModal not showing on Home/Results

* Export helper method to fix unit test

* Add ESLint jsx-a11y to package.json to fix tests

* Fix https and password type issue

* Add type=text to SearchForm text inputs

* Add fix for text input sizes

* Remove sdc-main css (unused)

* Feature/styles update tests (#36)

* Add unit test for exportCSV method

* Add unit tests for formQuery

* Fix method and add test for formatData

* Add unit tests for other helperMethods code

* Fix/refs search (#37)

* Add fix for refs searching, add new fields

- Add new fields for CRN, VAT, PAYE search on SearchForm

* Remove unused code in formQuery.js

* Remove load test part of Jenkinsfile

* Add stress tests back in, fix unit test

* Add new unit tests for new formQuery inputs

* Fix/react 16 migration (#38)

* Add start of React 15 -> 15 migration

- Remove use of halogen for loading spinner, use fork which is compatible with react 16
- Upgrade react-router dependancy

* Fix use of React 16 for searching

- Fixed all features apart from 404 page and use of react-modal-dialog

* Fix 404 page display

* Refactor SearchForm to be functional component

* Change SearchForm to use props, no deconstruct

* Refactor code base to use Panel, not a modal

- Remove react-modal-dialog from package.json (not compatible with React 16 + we shouldn't be using it anyway)
- Refactor all uses of ErrorMessage to use a Panel instead
- Add props to Panel so that a close link can be used

* Feature/child refs hoc (#39)

* Refactor fetching of child refs into HOC

- ChildRefList/Table both have almost identical code for fetching /business/:id, so the common logic has been moved into a higher order component

* Add working use of HOC in ChildRefTable

* Fix/error modal bug (#40)

* Add fix for ChildRefList, use props not this.state

* Add fix for ChildRefTable, use props not state

* Fix/styles feedback fix (#43)

* Fix Button to use dynamic style/class props

- For the clear button, use secondary button type with border

* Remove username from Header.js

* Fix use of show references icons

- Add /img to /public
- Add chevron image to /src/resources

* Add capped badge if the results are capped

- Results cap at 10,000

* Add updated CSS for new search bar

* Seperate out SearchForm into different components

- Change props for button/textInput

* Add seperate search form for the home page

- Fix issue with TextInputInline not displaying the correct size

* Add fix for width of react-table (12 cols now)

* Fix column widths, fix issue with htmlFor in range input

* Fix more col widths, remove scroll in ResultsList

* Remove spacing from Home search inputs

* Fix spelling errors

- CN -> CRN
- Use 'Employment' instead of 'Employment Bands' in react table

* Add scroll to results feature

* Change scroll to go to Search header

* Feature/results capped at (#44)

* Add return of 'x-total-count' header

* Add display of panel showing number of results capped

- Add reducer/apiActions for setting capped results number
- Add allowed cors headers in the server for X-Total-Count
- Add return of X-Total-Count in apiGateway and api.js
- Modify accessApi.js to handle getting the headers

* Add unit test for new helperMethod

* Fix/mock fetch headers (#45)

* Add fix for mock fetch change of format

- From accessAPI we get a promise back with the response rather than a promise for the json

* Add better explanation of fetch issue

* Fix/export convert bands (#46)

* Add redux related code for exporting csv or json

* Add conversion of bands in csv/json download

* Use redux for the export of csv/json

* Add tests for export.js util

* Fix ESLint error (define before use)

* Fix/json fields update (#47)

* Fix JSON field accessor names

* Fix JSON fields in export.js

* Fix JSON fields for fake fetch functionality

* Fix tests with new JSON keys
awharris pushed a commit to ONSdigital/business-index-ui that referenced this issue Sep 21, 2018
* Feature/skeleton (#1)

* Add skeleton bi-ui frontend, mostly a clone of sbr-ui

- Cloned sbr-ui, replaced all sbr related code to bi, apart from apiActions

* Change apiActions to match business index format

* Add prototype UBRN search

* Add working UBRN search using react-table

* Add in pagination prop for UBRN results table

* Feature/range match search (#2)

* Fix validation for UBRN search

- Add config file for valid refs

* Add ONS inputs for Match search, used SDC styles

- Used Less to isolate SDC styles, prefix with 'sdc-isolation' to prevent conflicts with other styles

* Add inputs for Match search

- Add bands to utils/convertBands.js

* Add code for working Match search

- Uses all inputs

* Fix reload of Match data

- When going from match -> Home or another page, the data will be reloaded into the search inputs when you go back
- Turn off eslint rule

* Fix issue with clearing of Select boxes

* Remove UPRN field from Match page

* Add react-select input with working aria-hidden

- Use 'hacky' bit of js to fix buggy react-select component, on any update, look for classNames within react-select with an aria-hidden tag and change them
- Add filterable toggle (checkbox) to match search

* Refactor MatchForm, use seperate Components

- Move TextInput and SelectInput to seperate files
- Fix PropTypes

* Add scroll to results on search for Match

* Fix scroll to bottom on search feature

* Fix focus on first input after resetting the form

* Add minor fixes to UBRN page, naming etc.

* Fix naming of SearchRefForm -> UBRNForm

* Use CheckBoxInput component in Match

* Add fixed code for RangeSearch query

* Fix persistance of multiple select input values

* Fix bug for Clear button not clearing all the data

* Move SelectMultipleInput code to seperate file

* Add TextInputInline component for dual inputs

- i.e. for min/max inputs

* Fix use of filter props in RangeForm

* Add working RangeQuery search

- Add new formatter method in utils/formQuery.js
- Add (currently unused) consts in ApiConstants
- Fix apiAction for RangeQuery

* Fix formatRangeQuery, remove debugging statements

* Fix showFilter bug, shows after new search

* Transform businessName to upper case

* Add encodeSpecialChars method to formQuery

- For encoding businessName
- Copied method from business-index-ui

* Fix/initial refactor (#4)

* Add table of contents and description to README

* Fix README table of contents

* Add fix for redux reset store JSON issue

- See #3 for more details

* Add example expand view to Match

* Remove init query code to '' rather than {}

- This was causing bugs on refresh

* Fix/authentication (#5)

* Add mock API Gateway related code

- Copy from sbr-ui fix/authentication

* Migrate sbr-ui fix/authentication code to bi-ui

- Remove unused dependancies (jwt)
- Fix LoginActions/auth.js to mimick sbr-ui
- Add base64 encoding to LoginActions
- Use base64 for encoding username:password rather than bcrypt in the mock gateway
- Fix saving of accessToken in sessionStorage

* Fix rerouting of API requests to work for bi

- Change URL to localhost:9000 (business-index-api)

* Fix/deployment (#6)

* Fix server routes tests

* Fix Gitlab URL in Jenkinsfile

- Fix replacement URLs for Sed for API Gateway

* Fix Gitlab config to use correct branch

* Fix Gitlab credentialsId

* Remove POST body from 'prod' code

* Add testing code for using ENV variables

* Add debugging statements to node server

- For debugging in CF

* Change gitlab credentials back to bi

* Add json:true to node server request

* Add family:4 to request options in node server

- request/request-promise-native#6

* Remove hardcoded basicAuth values

* Fix search enpoint config

* Fix formQuery config, no need for & in query

* Remove debugging statements, console logs etc.

* Add logging config from sbr-ui

- Add filename to logs
- Use proper morgan logging with Winston logger

* Update Jenkinsfile with new configuration

- Build node 'GMU' label

* Add code for ShowConfetti, in server + frontend (#7)

- Copy showConfetti code from sbr-ui

* Fix/user feedback (#8)

* Add fix for PostCode on Match form

- Add value prop

* Add SummaryTable component for useful stats

- For num results + capped results

* Add ChildRefTable component for child references

- Not using Redux, just using fetch() inside the component

* Add siccodes conversion JSON

- Add SIC code conversion to expand view

* Add ResultsTable component

* Add additional props into ResultsTable

- DefaultPageSize, pagination etc.

* Fix clear functionality for UBRN search

- Focus on UBRN input after clear

* Remove comments, add config for /business endpoint

* Add proper formatting of ExpandView JSON

* Add Business Index description on Home page

* Fix Logout logic, handle 500's

- If there is a server error whilst logging out, the user will still be logged out

* Clear sessionStorage rather than localStorage

* Fix/console warnings (#9)

* Remove unused scripts from index.html

- Remove ONS JS & Jquery

* Fix key error in SummaryTable

* Fix role in reducer and node server

- Add 'role' back into login reducer
- Fix role returns in utils/auth.js
- Add role return into checkToken route in the node server

* Fix console warnings

- Unused imports etc.

* Fix propTypes errors

- Mostly related to the value prop

* Fix propType errors for ShowConfetti

* Add fix for IndustryCode inputs

- Use encoded square brackets

* Add fixes for industry code & refs bugs

- Fix use of industry code conversion
- Fix max number of refs not showing (bug in reduce function)

* Fix/cn expand view (#10)

* Add fix for CN display in helperMethods

* Remove debugging statement

* Feature/convert bands (#11)

* Add *bands conversion to ResultsTable

- Show the actual value rather than 'A' or '1' etc.

* Add checkBox for convertBands onto Match/Range

- Can toggle whether or not to use convertBands in the ResultsTable

* Fix passing of props to RangeForm

* Fix checkBoxes to be inline

- Use SDC grid

* Feature/export to csv (#12)

* Add export to csv functionality

- Using utils/export
- Copied from the business-index-ui

* Add config/export with name of CSV

* Add export to JSON button to ResultsTable

* Feature/ch link (#13)

* Add ch link in child refs table

* Add security fix for target="_blank"

* Fix/env vars (#14)

* Add new Jenkinsfile

* Update react-scripts so env vars can be used

- Update to 0.2.3 so we can use environment variables

* Use env vars for URLS in the frontend

* Add server environment variables

* Add updated Jenkinsfile

* Add debugging statements

* Remove debugging statements, fix Jenkinsfile

* Remove unused manifest.yml

* Fix/node server refactor (#15)

* Add refactored node server with seperate routes

- Move routes to /routes/...
- Do node config in index.js
- Use proper session management

* Refactor react code to integrate with new server

- For checkToken, put the token in an Authorization header

* Remove npm-run-script from package.json

* Fix README to include new running details

* Remove use of npm run script from Jenkinsfile

* Change server test config

- When you run npm run test-server, it will run the test that builds the project first, before running the other tests recursively in /server-test-spec

* Use test:type rathe than test-type

* Fix server tests, use seperate files

- The test:server runs the server.test.js first, which tests the npm run build command and the serving of static assets, the api/auth functionality are then tested, by recursively testing all files in /test/server-test-spec/*

* Remove unused component tests, unused dependancies

- Remove unused component tests + package.json test script
- Refactor dependancies in package.json, move test ones to devDeps

* Change order of routes import in node server

- Fix /version

* Fix static files path

- Fix start command in package.json

* Fix/jenkinsfile branch name (#16)

* Add fixed Jenkinsfile, fix branch names

* Change Gitlab branch to develop

* Fix/error handling 404 (#17)

* Add fix for 404 no results error

* Fix display of error message

- use () => method so closeModal isn't called every render

* Refactor scroll to top feature, reduce duplication

* Fix errorModal on Login form

* Add fix for range search

- Use proper encoded [ and ]

* Fix npm cover script, use correct server test

* Feature/redis sessions (#18)

* Add redis sessions to /sessions

- Remove component testing section on README
- Add redis-sessions dependancy
- Change /helpers to /utilities

* Add more to the README description

* Feature/search hoc (#19)

* Remove unused results key in Match/Range

- Remove commented out method in UBRNLookup

* Add Search Higher Order Component

- This makes the individual search pages (Match/Range/UBRN) redundant, as those pages use almost identical functionality, we can move all the common logic (all of it) into a higher order component, which returns a component based upon the input settings
- Modify UBRN redux action to handle commonality between match + range

* Move search pages config into /config/search

* Add comment into SearchHOC, explain use of HOC

* Fix console warning, unused var

* Add convert bands checkbox into UBRNForm

* Fix showFIlter, set false for UBRNForm

* Add fix for buggy showFilter

* Fix/search view grids (#20)

* Add refactored grid for UBRN & Range forms

- Use sdc grid to fit more inputs on the screen and handle smaller screen sizes

* Refactor MatchForm grid, condense inputs

* Remove unused grid helper div from Range grid

* Remove unused grid div from UBRNForm

* Remove unused BreadCrumb component

- Using the pattern library instead

* Remove unused DeveloperView component

* Remove unused CSS + JS

- Mostly bootstrap related

* Feature/highlight business name (#21)

* Add highlighting of businessName to ResultsTable

- Add prop businessName to be passed in to ResultsTable
- Add highlighting of businessName, using a <span> with a background colour

* Add try catch for creating the Regex

* Fix businessName prop to only update on a search

- Rather than the highlighting live updating as the user types, it will just do the highlighting when the search button is pressed

* Fix bug where highlighting is removed

- When changing between Match/Range/UBRN, the highlighting would dissapear

* Fix/results table key error (#22)

* Add reformatted ResultsTable code

- Add spacing to a large line of code to increase readability

* Add fix for key error in ResultsTable

- If there are multiple matches for the highlight method, a key error would occur due to duplicate keys, fix this by using an index counter as part of the key
- An ESLint key rule had to be disabled, however as the UBRN is used as part of the key it shouldn't be an issue

* Feature/health route (#23)

* Add /api/health route to the node server

- Just returns 'OK' for now

* Add extra details to comment on new route

* Add health check step to Jenkinsfile

* Change /api/health route to return JSON not text

* Add assignment of curl response status to variable

* Add build fail trigger to Check Health stage

* Fix/redux refactor (#24)

* Remove unused redux code

- Remove unused setPeriod action, SET_PERIOD constant and reducer code
- Remove large comments stating basic redux patterns
- Remove config files for periods

* Refactor setResults/Headers to not use JSON

- Just set the actual variable rather than nexting in JSON

* Refactor redux actions to be more concise

- Rather than defining an action for each type of search, use one action but pass in an additional value, in our case, the json key of a redux store item, so SET_QUERY with 'match' or 'range'

* Remove obvious redux related comments

- Don't need to explain what a reducer is etc.

* Remove verbose comments in redux actions

- Don't need to explain what an action is

* Remove unused error message related redux code

- Just the top level error message json key in the store, not the nested error messages in ubrn/match/range

* Remove unused timestamp from error message

* Refactor ApiAction to use generic action creator

- Rather than using UBRN/Match/Range actions, just use one generic action creator called search which will work for all search types
- Remove unused api searches in /utils/apiSearch

* Fix/utils unit tests (#25)

* Add convertBands unit tests

* Remove unused helper method (already in convert bands)

* Remove unused helperMethods

* Add helper methods unit test

* Remove flow annotations from /utils

- Not needed for such a small codebase, parameter types will be documented in JSDoc style doc strings

* Remove flow related configuration

- Remove dependancy from package.json
- Remove flow config file, .flowconfig

* Remove flow details in CONTRIBUTING.md

* Add unit test for Sic code conversion

* Fix/jenkinsfile manifest (#26)

* Add fix for using manifest based on branch name

* Remove promote to beta section of Jenkinsfile

* Update node + npm engines version in package.json

* Update Jenkinsfile to work with new CF

- Update deploy part of the script, new CF URL

* Remove unused API_GW_URL variable

* Fix Jenkinsfile to use actual Gitlab dir names

* Feature/dot env (#27)

* Add .env file for loading environment variables

- Add dotenv dependancy to package.json
- Update react-scripts to 0.5.1
- Remove env vars from package.json scripts (just start scripts)
- Move favicon and index.html to /public

* Remove env var section from README

- Fix mistake, change Bootstrap Isolation to SDC Isolation

* Update Jenkinsfile to handle .env config

* Update Jenkinsfile Gitlab branch

* Remove env vars from Jenkinsfile

- Use .env instead

* Use global Jenkins variable in place of local one

* Remove unused Jenkinsfile variables

* Fix tests to manually fork apiGateway script

* Add test user/pass env vars into test scripts

* Fix/ping health route (#28)

* Add --insecure flag to Jenkinsfile curl request

* Add documentation for new curl request flag

* Fix/export csv refactor (#29)

* Add refactored exportCSV method

* Refactor exportCSV code to improve readability

- Change name of config variable to be more intuitive

* Add documentation to methods in /utils/export.js

* Fix/api request refactor (#30)

* Remove unused onChange method from auth.js

* Add refactored fetch usage for searching

- Add accessAPI which is basically a helper to preset some commonly used config for fetch

* Add refactored InfoActions with new fetch

- Use accessAPI method in InfoActions

* Refactor login action to use accessAPI

* Add refactored logout LoginAction

* Add refactored logout action in LoginActions

* Remove unused /utils files

- Use default export in accessAPI.js

* Add more informative api request error messages

* Fix wrong last update usage in Info page

* Fix Jenkinsfile library branch

- Use master, not a deleted branch

* Feature/dockerfile (#31)

* Add Dockerfile and .dockerignore file

* Add env var to apiGateway config

- Use passed in env var for server url, so that we can pass in a docker url

* Remove misc notes from dockerfile

* Update README with better running instructions

* Update Jenkinsfile shared pipeline branch

* Fix/fetch promise refactor (#32)

* Add refactored fetch using promises

- Use promise rather than callback to make code more concise
- Leave in old accessAPI method until other *Actions are refactored

* Add refactore InfoActions using promises

- Fix bug where spinner would continue showing if an error had occured

* Fix bug relating to catching failed promises

* Remove old apiAccess method

- Refactor *Actions to use new accessAPI method

* Fix display of ErrorModal

- Convert to pure component
- Fix child ref table to use ApiAccess for API requests

* Feature/mock backend api (#33)

* Fix use of favicon in index.html

- Use properly formatted path

* Add fake request which mocks fetch

- All API requests pass the type of request (search/business/uiInfo etc) into accessAPI, so that URL's don't have to be parsed to find the endpoint
- Add /utils/request.js which will use the mocked fetch when it's in a test environment (REACT_APP_ENV)

* Make promise forming method more concise

* Move fakeFetch code into requestUtils

- Refactor code into small methods
- Fix ESLint error

* Add request dependancy to server package.json

* Remove unused bcrypt dependancy

* Reduce setTimeout when doing a fakeRequest

* Add .env file (remove from .gitignore)

* Fix/session classes (#34)

* Add proper use of OO inheritance in Sessions

- Each type of session extends the Session class
- Add documentation of Session methods
- Add pg dependancy to package.json

* Update Jenkinsfile Gitlab branch

* Fix PsqlSession pool creation bug

- Fix bug where just importing the PsqlSession class would trigger a new pool to be created, move this to an init method which is called from the constructor

* Remove unused CI.md README

* Feature/styles update (#35)

* Change REACT_APP_ENV value to 'test'

* Add assets for the new pattern library

- Add css to the /public directory
- Add logo image to /src/resources/img
- Remove old styles css import in index.js
- Update index.html to handle new CSS

* Remove unused dependancies, refactor ESLint

- Remove unused dependancies in package.json (react a11y)
- Remove unused eslint config section from package.json
- Add .vscode to .gitignore
- Remove unused routes

* Remove unused React components and utils

- Remove any unused views/components/helper methods
- Remove reducer/action/constant code relating to get ui/api info
- Remove unused config

* Fix ESLint issue with arrow functions

* Add updated Login page

- Add LoginAction for resetting the error message
- Add /patterns with Button/TextInput/LinkButton components
- Fix routes in routes file

* Refactor login page to use TextInput components

- Refactor TextInput to make it work with either refs or onChange

* Fix routing issue, refactor functional components

- Fix issue with SearchHOC (don't use it for now)

* Add Panel component for showing error/info/warn

* Add working search feature back in

- Add components to deal with the search (Business, ResultsList etc)
- Add redirect in ApiActions
- Fix exportJson method

* Fix industry code and multiple select inputs

* Remove unused files, refactor SearchHOC

- Remove unused assets
- Move onChange helpers to helperMethods for SearchHOC

* Fix issue with depracated replaceState params

* Fix documentation in all React classes

- Ensure documentation is consistent, e.g. no need to duplicate
prop details

* Refactor Redux related code, remove unused code

- Remove unused redux code (related to Match/range/ubrn)
- Move helper methods to /utils/helperMethods.js

* Fix documentation formatting

- Use consistent documentation format, where the parameters are only described where prop types isn't used

* Remove unused object.assign dependancy

* Remove verbose testing details from the README

* Add Pagination component and connect to Results

* Fix issue with <table> child, use <tbody>

- https://stackoverflow.com/questions/41716528/react-tr-cannot-appear-as-a-child-of-td-see-comment-td-tr

* Add ChildRefList component of child refs

* Fix ESLint errors

* Fix forming of the ES query

- Fix form query to work for generic queries
- Change env var back to local

* Use immutable set state, no mutating of state

- Use ES6 way of setting state immutably

* Add fix for searching on child ref (VAT/CH/PAYE)

* Fix use of plural businesses on Results page

* FIx issue with errorModal not showing on Home/Results

* Export helper method to fix unit test

* Add ESLint jsx-a11y to package.json to fix tests

* Fix https and password type issue

* Add type=text to SearchForm text inputs

* Add fix for text input sizes

* Remove sdc-main css (unused)

* Feature/styles update tests (#36)

* Add unit test for exportCSV method

* Add unit tests for formQuery

* Fix method and add test for formatData

* Add unit tests for other helperMethods code

* Fix/refs search (#37)

* Add fix for refs searching, add new fields

- Add new fields for CRN, VAT, PAYE search on SearchForm

* Remove unused code in formQuery.js

* Remove load test part of Jenkinsfile

* Add stress tests back in, fix unit test

* Add new unit tests for new formQuery inputs

* Fix/react 16 migration (#38)

* Add start of React 15 -> 15 migration

- Remove use of halogen for loading spinner, use fork which is compatible with react 16
- Upgrade react-router dependancy

* Fix use of React 16 for searching

- Fixed all features apart from 404 page and use of react-modal-dialog

* Fix 404 page display

* Refactor SearchForm to be functional component

* Change SearchForm to use props, no deconstruct

* Refactor code base to use Panel, not a modal

- Remove react-modal-dialog from package.json (not compatible with React 16 + we shouldn't be using it anyway)
- Refactor all uses of ErrorMessage to use a Panel instead
- Add props to Panel so that a close link can be used

* Feature/child refs hoc (#39)

* Refactor fetching of child refs into HOC

- ChildRefList/Table both have almost identical code for fetching /business/:id, so the common logic has been moved into a higher order component

* Add working use of HOC in ChildRefTable

* Fix/error modal bug (#40)

* Add fix for ChildRefList, use props not this.state

* Add fix for ChildRefTable, use props not state

* Fix/styles feedback fix (#43)

* Fix Button to use dynamic style/class props

- For the clear button, use secondary button type with border

* Remove username from Header.js

* Fix use of show references icons

- Add /img to /public
- Add chevron image to /src/resources

* Add capped badge if the results are capped

- Results cap at 10,000

* Add updated CSS for new search bar

* Seperate out SearchForm into different components

- Change props for button/textInput

* Add seperate search form for the home page

- Fix issue with TextInputInline not displaying the correct size

* Add fix for width of react-table (12 cols now)

* Fix column widths, fix issue with htmlFor in range input

* Fix more col widths, remove scroll in ResultsList

* Remove spacing from Home search inputs

* Fix spelling errors

- CN -> CRN
- Use 'Employment' instead of 'Employment Bands' in react table

* Add scroll to results feature

* Change scroll to go to Search header

* Feature/results capped at (#44)

* Add return of 'x-total-count' header

* Add display of panel showing number of results capped

- Add reducer/apiActions for setting capped results number
- Add allowed cors headers in the server for X-Total-Count
- Add return of X-Total-Count in apiGateway and api.js
- Modify accessApi.js to handle getting the headers

* Add unit test for new helperMethod

* Fix/mock fetch headers (#45)

* Add fix for mock fetch change of format

- From accessAPI we get a promise back with the response rather than a promise for the json

* Add better explanation of fetch issue

* Fix/export convert bands (#46)

* Add redux related code for exporting csv or json

* Add conversion of bands in csv/json download

* Use redux for the export of csv/json

* Add tests for export.js util

* Fix ESLint error (define before use)

* Fix/json fields update (#47)

* Fix JSON field accessor names

* Fix JSON fields in export.js

* Fix JSON fields for fake fetch functionality

* Fix tests with new JSON keys
@tnovau
Copy link

tnovau commented Nov 30, 2018

Hey, I'm getting the same issue here, familiy: 4 is not working for me...

OS: Mac OSX Sierra
yarn: 1.12.3
npm: 6.4.1
Node: v8.12.0

Request options: {
body:undefined
headers:Object {x-app-platform: "Android"}
json:true
method:"GET"
uri:"http://someurl/api/v2/version/tag/3.0.1"
}

I'm getting the error only running it with npm (e.g npm run start:dev).

{ Error: getaddrinfo ENOTFOUND someurl.com someurl.com:80
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'someurl.com',
host: 'someurl.com',
port: 80 }

@jstephens7
Copy link

Try passing the url through encodeURI. That was the issue for me.

Request options: {
body:undefined
headers:Object {x-app-platform: "Android"}
json:true
method:"GET"
uri: encodeURI("http://someurl/api/v2/version/tag/3.0.1")
}

@sakurayang
Copy link

sakurayang commented Sep 24, 2019

I'm getting the same issue here, both of encodeURI and familiy: 4 are not working for me.
OS: WSL
node: v10.13.0
npm: v6.9.0
Request options:

{
body:undefined
headers:undefined
json:true
method:"GET"
uri:"https://s.search.bilibili.com/cate/search?main_ver=v3&pagesize=1&search_type=video&view_type=hot_rank&cate_id=28&page=1&time_from=20190920&time_to=20190921"
}

the number of page is over 1000 ,and i write a for loop to get data from page 1 to page n
And I get the error randomly like below

{ RequestError: Error: getaddrinfo ENOTFOUND s.search.bilibili.com s.search.bilibili.com:443
  message:
   'Error: getaddrinfo ENOTFOUND s.search.bilibili.com s.search.bilibili.com:443',
  cause:
   { Error: getaddrinfo ENOTFOUND s.search.bilibili.com s.search.bilibili.com:443
       at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
     errno: 'ENOTFOUND',
     code: 'ENOTFOUND',
     syscall: 'getaddrinfo',
     hostname: 's.search.bilibili.com',
     host: 's.search.bilibili.com',
     port: 443 },
  error:
   { Error: getaddrinfo ENOTFOUND s.search.bilibili.com s.search.bilibili.com:443
       at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
     errno: 'ENOTFOUND',
     code: 'ENOTFOUND',
     syscall: 'getaddrinfo',
     hostname: 's.search.bilibili.com',
     host: 's.search.bilibili.com',
     port: 443 },
  options:
   { family: 4,
     uri:some_uri,
     method: 'GET',
     callback: [Function: RP$callback],
     transform: undefined,
     simple: true,
     resolveWithFullResponse: false,
     transform2xxOnly: false },
  response: undefined }

@himanshush13
Copy link

hello @tnovau , Have you got anything related to your error, I am too getting the same while running npm start.

@himanshush13
Copy link

image

This is the error, I am getting on Azure

@tnovau
Copy link

tnovau commented May 13, 2020

hello @tnovau , Have you got anything related to your error, I am too getting the same while running npm start.

Sorry, I'm not using this library anymore.

@piall
Copy link

piall commented Aug 30, 2020

Try passing the url through encodeURI. That was the issue for me.

Request options: {
body:undefined
headers:Object {x-app-platform: "Android"}
json:true
method:"GET"
uri: encodeURI("http://someurl/api/v2/version/tag/3.0.1")
}

Thanks it worked for me😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants