mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 21:03:29 +03:00
fa84808048
no issue Since `ember-moment@10.0` it's not been necessary to use the `ember-cli-moment-shim` package, with `moment` instead being usable directly via `ember-auto-import`. Getting rid of the shim package is necessary for compatibility with `embroider`, Ember's new build tooling. - dropped `ember-cli-moment-shim` dependency - added `moment-timezone` dependency and updated all imports to reflect the different package - worked around `ember-power-calendar` having `ember-cli-moment-shim` as a sub-dependency - added empty in-repo-addon `ember-power-calendar-moment` to avoid `ember-power-calendar` complaining about a missing package - added `ember-power-calendar-utils` in-repo-addon that is a copy of `ember-power-calendar-moment` but without the build-time renaming of the tree for better compatibility with embroider
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import moment from 'moment-timezone';
|
|
import {Response} from 'miragejs';
|
|
import {paginatedResponse} from '../utils';
|
|
|
|
export default function mockInvites(server) {
|
|
server.get('/invites/', paginatedResponse('invites'));
|
|
|
|
server.get('/invites/:id', function (schema, request) {
|
|
let {id} = request.params;
|
|
let invite = schema.invites.find(id);
|
|
|
|
return invite || new Response(404, {}, {
|
|
errors: [{
|
|
type: 'NotFoundError',
|
|
message: 'Invite not found.'
|
|
}]
|
|
});
|
|
});
|
|
|
|
server.post('/invites/', function ({invites}) {
|
|
let attrs = this.normalizedRequestAttrs();
|
|
let oldInvite = invites.findBy({email: attrs.email});
|
|
|
|
if (oldInvite) {
|
|
oldInvite.destroy();
|
|
}
|
|
|
|
/* eslint-disable camelcase */
|
|
attrs.token = `${invites.all().models.length}-token`;
|
|
attrs.expires = moment.utc().add(1, 'day').valueOf();
|
|
attrs.createdAt = moment.utc().format();
|
|
attrs.createdBy = 1;
|
|
attrs.updatedAt = moment.utc().format();
|
|
attrs.updatedBy = 1;
|
|
attrs.status = 'sent';
|
|
/* eslint-enable camelcase */
|
|
|
|
return invites.create(attrs);
|
|
});
|
|
|
|
server.del('/invites/:id/');
|
|
}
|