feat: async/await

This commit is contained in:
Barış Soner Uşaklı
2019-08-12 21:56:09 -04:00
parent 3cc7ec63e8
commit 7beef91c3f
3 changed files with 29 additions and 50 deletions

View File

@@ -1,16 +1,13 @@
'use strict';
const async = require('async');
const nconf = require('nconf');
const db = require('../database');
module.exports.ping = function (req, res, next) {
async.waterfall([
function (next) {
db.getObject('config', next);
},
function () {
res.status(200).send(req.path === nconf.get('relative_path') + '/sping' ? 'healthy' : '200');
},
], next);
module.exports.ping = async function (req, res, next) {
try {
await db.getObject('config');
res.status(200).send(req.path === nconf.get('relative_path') + '/sping' ? 'healthy' : '200');
} catch (err) {
next(err);
}
};