Started on DBv1 migration
This commit is contained in:
30
app/imports/migrations/methods/getVersion.js
Normal file
30
app/imports/migrations/methods/getVersion.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||
import { assertAdmin } from '/imports/api/sharing/sharingPermissions.js';
|
||||
import { Migrations } from 'meteor/percolate:migrations';
|
||||
|
||||
const dbVersionToGitVersion = {
|
||||
0: '2.0-beta.32 and lower',
|
||||
1: '2.0-beta.33',
|
||||
}
|
||||
|
||||
const getVersion = new ValidatedMethod({
|
||||
name: 'admin.getVersion',
|
||||
validate: null,
|
||||
mixins: [RateLimiterMixin],
|
||||
rateLimit: {
|
||||
numRequests: 5,
|
||||
timeInterval: 5000,
|
||||
},
|
||||
run() {
|
||||
if (Meteor.isClient) return;
|
||||
assertAdmin(this.userId);
|
||||
const dbVersion = Migrations.getVersion();
|
||||
return {
|
||||
dbVersion,
|
||||
gitVersion: dbVersionToGitVersion[dbVersion],
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default getVersion;
|
||||
Reference in New Issue
Block a user