2016-06-19 18:02:32 +08:00
|
|
|
/* eslint func-names:0 */
|
|
|
|
|
2016-06-23 15:49:22 +08:00
|
|
|
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;
|
2016-06-23 15:49:22 +08:00
|
|
|
return DatabaseConnector.forAccount(account.id);
|
2016-06-19 18:02:32 +08:00
|
|
|
});
|
2016-07-09 08:13:30 +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
|
2016-07-09 08:13:30 +08:00
|
|
|
}, {apply: true});
|
2016-06-19 18:02:32 +08:00
|
|
|
}
|