Skip to content

Commit

Permalink
Dont use deprecated callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
daleharvey committed Jun 10, 2016
1 parent 6ace6a4 commit d9d2111
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/routes/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ module.exports = function(app, PouchDB) {
// Create a database
app.put('/:db', jsonParser, function (req, res, next) {
var name = encodeURIComponent(req.params.db);
new PouchDB(name, function (err, db) {
if (err) return res.status(412).send(err);
var db = new PouchDB(name);
db.info().then(function() {
res.status(201).send({ok: true});
}).catch(function(err) {
res.status(412).send(err);
});
});

Expand All @@ -28,11 +30,8 @@ module.exports = function(app, PouchDB) {
['/:db/*','/:db'].forEach(function (route) {
app.all(route, function (req, res, next) {
var name = encodeURIComponent(req.params.db);
new PouchDB(name, function (err, db) {
if (err) return res.status(412).send(err);
req.db = db;
next();
});
req.db = new PouchDB(name);
next();
});
});

Expand Down

0 comments on commit d9d2111

Please sign in to comment.