Sometimes I find myself wanting to execute some privileged code on the server while the app is running. For example, I may want to quickly delete a document in a collection (when the client-side is blocked from doing so). Or, I may want to quickly try out server-side functions like Email.send
and Accounts.createUser
.
So what are some of the ways of achieving this? I'm concerned with both cases of how an meteor app can be run:
meteor
commandUltimately, I'd also like to setup cron jobs that can execute some code in the Meteor context. Is this directly achievable or doable through workarounds?
Thanks for the help!
Couldn't you just write server-side methods that only work for your user? Then expose those with Meteor.methods
and run them in the client console. That's what I do when I want to test eg. Email.send
. You could also go a step further and write a rudimentary admin UI.
For instance, on the server:
Meteor.methods({
test_sendEmail: function(options) {
if (this.userId != adminUserId) return; // don't execute unless admin
Email.send(options);
}
});
On the client:
Meteor.call("test_sendEmail", {to: "[email protected]", subject: "Foo", text: "Bar"});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With