-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/1500-seeing-service-capacity-when-it-is-…
…not-applicable
- Loading branch information
Showing
13 changed files
with
577 additions
and
15,023 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const expect = require('chai').expect; | ||
|
||
const concatenateAddress = require('../../../utils/concatenateAddress').concatenateAddress; | ||
|
||
describe('concatenateAddress', () => { | ||
it('should only return address line 1 when only line 1 passed in', () => { | ||
expect(concatenateAddress('Test Address Line 1')).to.equal('Test Address Line 1'); | ||
}); | ||
|
||
it('should concatenate all lines with spaces between when all provided', () => { | ||
expect(concatenateAddress('A', 'B', 'C', 'D', 'E')).to.equal('A B C D E'); | ||
}); | ||
|
||
it('should concatenate with single spaces between when address lines 2 and 3 are missing but town and county exist', () => { | ||
expect(concatenateAddress('A', undefined, undefined, 'D', 'E')).to.equal('A D E'); | ||
}); | ||
}); |
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
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
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,33 +1,31 @@ | ||
|
||
const config = require('../../config/config'); | ||
const RateLimit = require('express-rate-limit'); | ||
const RedisStore = require('rate-limit-redis'); | ||
const expressRateLimit = require('express-rate-limit'); | ||
const { RedisStore } = require('rate-limit-redis'); | ||
const RedisClient = require('ioredis'); | ||
const isCI = require('is-ci'); | ||
|
||
const redisClient = new RedisClient(config.get('redis.url')); | ||
const store = isCI | ||
? undefined | ||
: new RedisStore({ | ||
redisURL: config.get('redis.url'), | ||
sendCommand: (...args) => redisClient.call(...args), | ||
}); | ||
|
||
const rateLimiterConfig = { | ||
store, | ||
delayMs: 0, // disable delaying - full speed until the max limit is reached | ||
passIfNotConnected: true, | ||
windowMs: 60 * 1000, // 1 minute | ||
windowMs: 60 * 1000, // 1 minute | ||
}; | ||
|
||
const authLimiter = isCI | ||
const nhsBsaApiLimiter = isCI | ||
? (req, res, next) => { | ||
next(); | ||
} | ||
: new RateLimit({ | ||
: expressRateLimit.rateLimit({ | ||
...rateLimiterConfig, | ||
max: 100, // maximum number of requests allowed in the windowMs | ||
prefix: 'auth:', | ||
limit: 200, // maximum number of requests allowed in the windowMs | ||
prefix: 'nhsBsaApi:', | ||
}); | ||
|
||
|
||
|
||
module.exports.authLimiter = authLimiter; | ||
|
||
module.exports.nhsBsaApiLimiter = nhsBsaApiLimiter; |