Mailspring/packages/nylas-api/decorators/connections.js

17 lines
485 B
JavaScript
Raw Normal View History

2016-06-19 18:02:32 +08:00
/* eslint func-names:0 */
const {DatabaseConnector} = require(`nylas-core`);
2016-06-19 18:02:32 +08:00
module.exports = (server) => {
server.decorate('request', 'getAccountDatabase', function () {
const account = this.auth.credentials;
return DatabaseConnector.forAccount(account.id);
2016-06-19 18:02:32 +08:00
});
server.decorate('request', 'logger', (request) => {
2016-07-12 02:47:42 +08:00
if (request.auth.credentials) {
return global.Logger.forAccount(request.auth.credentials)
}
return global.Logger
}, {apply: true});
2016-06-19 18:02:32 +08:00
}