forked from chrisleekr/binance-trading-bot
-
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.
feat: account balance quote estimates for bot's currently handling as…
…sets (chrisleekr#353)
- Loading branch information
Alessandro Marchioro
authored
Oct 11, 2021
1 parent
06eb81b
commit 2ad3c71
Showing
7 changed files
with
81 additions
and
21 deletions.
There are no files selected for viewing
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,26 @@ | ||
/* eslint-disable global-require */ | ||
describe('webserver/handlers/status', () => { | ||
const appMock = {}; | ||
|
||
let resSendMock; | ||
|
||
beforeEach(async () => { | ||
resSendMock = jest.fn().mockResolvedValue(true); | ||
appMock.get = jest.fn().mockImplementation((_path, func) => { | ||
func(null, { send: resSendMock }); | ||
}); | ||
const loggerMock = require('../../../../helpers/logger'); | ||
|
||
const { handleStatus } = require('../status'); | ||
|
||
await handleStatus(loggerMock, appMock); | ||
}); | ||
|
||
it('triggers res.send', () => { | ||
expect(resSendMock).toHaveBeenCalledWith({ | ||
success: true, | ||
status: 200, | ||
message: 'OK' | ||
}); | ||
}); | ||
}); |
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,24 +1,11 @@ | ||
const requestIp = require('request-ip'); | ||
|
||
const handleStatus = async (funcLogger, app) => { | ||
const logger = funcLogger.child({ endpoint: '/status' }); | ||
|
||
app.route('/status').get(async (req, res) => { | ||
const clientIp = requestIp.getClientIp(req); | ||
|
||
logger.info( | ||
{ | ||
clientIp | ||
}, | ||
'handle status monitoring endpoint' | ||
); | ||
|
||
return res.send({ | ||
app.get('/status', (req, res) => | ||
res.send({ | ||
success: true, | ||
status: 200, | ||
message: 'OK' | ||
}); | ||
}); | ||
}) | ||
); | ||
}; | ||
|
||
module.exports = { handleStatus }; |
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