minor codestyle fixes, turn async/await in metricsApp into a conventional promise

This commit is contained in:
Konstantin Pogorelov
2022-06-18 12:23:59 +02:00
parent 1b52c6f46e
commit 2d2b253567
3 changed files with 16 additions and 15 deletions

View File

@@ -3,8 +3,8 @@
test:
npm test
lint:
node_modules/eslint/bin/eslint.js src
node_modules/.bin/dtslint types
npx eslint src
npm run dtslint-next
coverage:
node_modules/istanbul/lib/cli.js cover \
-i 'src/*' \

View File

@@ -206,7 +206,7 @@ describe('index', () => {
bypass: (req)=> {
// metrics added here to attempt skipping /metrics
// this should fail though, because serving /metrics preceeds bypassing
return !!req.url.match(/test|bad.word|metrics/)
return !!req.url.match(/test|bad.word|metrics/);
}
});
app.use(instance);

View File

@@ -206,9 +206,10 @@ function main(opts) {
};
if (opts.metricsApp) {
opts.metricsApp.get(opts.metricsPath || '/metrics', async (req, res, next) => {
opts.metricsApp.get(opts.metricsPath || '/metrics', (req, res) => {
res.set('Content-Type', opts.promRegistry.contentType);
return res.end(await opts.promRegistry.metrics());
opts.promRegistry.metrics()
.then(metrics => res.end(metrics));
});
}