@wepublish/api
Version:
API core for we.publish.
24 lines • 962 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.upsertPeerProfile = void 0;
const tslib_1 = require("tslib");
const api_1 = require("../../../../permissions-api/src");
const permissions_1 = require("../permissions");
const upsertPeerProfile = (input, hostURL, authenticate, peerProfile) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const { roles } = authenticate();
(0, permissions_1.authorise)(api_1.CanUpdatePeerProfile, roles);
const oldProfile = yield peerProfile.findFirst({});
const data = oldProfile
? yield peerProfile.update({
where: {
id: oldProfile.id
},
data: input
})
: yield peerProfile.create({
data: input
});
return Object.assign(Object.assign({}, data), { hostURL });
});
exports.upsertPeerProfile = upsertPeerProfile;
//# sourceMappingURL=peer-profile.private-mutation.js.map