2020-11-02 18:58:07 +00:00
|
|
|
|
|
|
|
const SyncEngine = require('../../util/sync-engine');
|
2020-09-21 11:24:43 +00:00
|
|
|
|
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethod('sync', {
|
|
|
|
description: 'Synchronizes the user with the other user databases',
|
|
|
|
http: {
|
|
|
|
path: `/sync`,
|
|
|
|
verb: 'PATCH'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Self.sync = async function() {
|
2020-11-02 18:58:07 +00:00
|
|
|
let engine = new SyncEngine();
|
|
|
|
await engine.init(Self.app.models);
|
2020-09-21 11:24:43 +00:00
|
|
|
|
|
|
|
let err;
|
|
|
|
try {
|
2020-11-02 18:58:07 +00:00
|
|
|
await engine.syncRoles();
|
2020-09-21 11:24:43 +00:00
|
|
|
} catch (e) {
|
|
|
|
err = e;
|
|
|
|
}
|
|
|
|
|
2020-11-02 18:58:07 +00:00
|
|
|
await engine.deinit();
|
2020-09-21 11:24:43 +00:00
|
|
|
if (err) throw err;
|
|
|
|
};
|
|
|
|
};
|