wip wiring up account forms
This commit is contained in:
parent
cdc15f019d
commit
3459bf26f8
25 changed files with 413 additions and 53 deletions
52
imports/api/Documents/methods.js
Normal file
52
imports/api/Documents/methods.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { check } from 'meteor/check';
|
||||
import Documents from './Documents';
|
||||
import rateLimit from '../../modules/rate-limit';
|
||||
|
||||
Meteor.methods({
|
||||
'documents.insert': function documentsInsert(doc) {
|
||||
check(doc, {
|
||||
title: String,
|
||||
body: String,
|
||||
});
|
||||
|
||||
try {
|
||||
return Documents.insert({ owner: this.userId, ...doc });
|
||||
} catch (exception) {
|
||||
throw new Meteor.Error('500', exception);
|
||||
}
|
||||
},
|
||||
'documents.update': function documentsUpdate(doc) {
|
||||
check(doc, {
|
||||
_id: String,
|
||||
title: String,
|
||||
body: String,
|
||||
});
|
||||
|
||||
try {
|
||||
Documents.update(doc._id, { $set: doc });
|
||||
return doc._id; // Return _id so we can redirect to document after update.
|
||||
} catch (exception) {
|
||||
throw new Meteor.Error('500', exception);
|
||||
}
|
||||
},
|
||||
'documents.remove': function documentsRemove(documentId) {
|
||||
check(documentId, String);
|
||||
|
||||
try {
|
||||
return Documents.remove(documentId);
|
||||
} catch (exception) {
|
||||
throw new Meteor.Error('500', exception);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
rateLimit({
|
||||
methods: [
|
||||
'documents.insert',
|
||||
'documents.update',
|
||||
'documents.remove',
|
||||
],
|
||||
limit: 5,
|
||||
timeRange: 1000,
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue