mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 11:22:19 +03:00
a3f3a56589
no-issue members-api uses async functions internally which return non-bluebird promises, so the `return` method wasn't availiable.
66 lines
1.6 KiB
JavaScript
66 lines
1.6 KiB
JavaScript
// NOTE: We must not cache references to membersService.api
|
|
// as it is a getter and may change during runtime.
|
|
const membersService = require('../../services/members');
|
|
const common = require('../../lib/common');
|
|
|
|
const members = {
|
|
docName: 'members',
|
|
browse: {
|
|
options: [
|
|
'limit',
|
|
'fields',
|
|
'filter',
|
|
'order',
|
|
'debug',
|
|
'page'
|
|
],
|
|
permissions: true,
|
|
validation: {},
|
|
query(frame) {
|
|
return membersService.api.members.list(frame.options);
|
|
}
|
|
},
|
|
|
|
read: {
|
|
headers: {},
|
|
data: [
|
|
'id',
|
|
'email'
|
|
],
|
|
validation: {},
|
|
permissions: true,
|
|
async query(frame) {
|
|
const member = await membersService.api.members.get(frame.data, frame.options);
|
|
if (!member) {
|
|
throw new common.errors.NotFoundError({
|
|
message: common.i18n.t('errors.api.members.memberNotFound')
|
|
});
|
|
}
|
|
return member;
|
|
}
|
|
},
|
|
|
|
destroy: {
|
|
statusCode: 204,
|
|
headers: {},
|
|
options: [
|
|
'id'
|
|
],
|
|
validation: {
|
|
options: {
|
|
id: {
|
|
required: true
|
|
}
|
|
}
|
|
},
|
|
permissions: true,
|
|
async query(frame) {
|
|
frame.options.require = true;
|
|
await membersService.api.members.destroy(frame.options);
|
|
return null;
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = members;
|