Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Meteor } from 'meteor/meteor'
import { UserData, Wallet, Problems, ProblemImages, ProblemComments, developmentValidationEnabledFalse } from '/imports/api/indexDB'
import SimpleSchema from 'simpl-schema';
import { check } from 'meteor/check'
import { sendMessage } from '/imports/api/activityLog/methods'
SimpleSchema.defineValidationErrorTransform(error => {
const ddpError = new Meteor.Error(error.message);
ddpError.error = 'validation-error';
ddpError.details = error.details[0].message;
return ddpError;
});
export const newProblem = new ValidatedMethod({
name: 'newProblem',
validate: new SimpleSchema(Problems.schema.pick("type","header","text","images","images.$","bounty"), {
requiredByDefault: developmentValidationEnabledFalse
}).validator({clean:true}),
run({ type, header, text, images, bounty }) {
if (Meteor.userId()) {
if (bounty > 0) { // check if the user can finance the bounty
Meteor.startup(() => {
// configure the password reset email via the accounts-password package
setupPasswordResetEmail();
// configure the account enrollment email via the accounts-password package
setupEnrollAccountEmail();
// configure accounts validation via the accounts-password package
setupAccountsValidation();
// publications
// setupUsersAdminPublication();
// enable Meteor.Error to be thrown for validation errors in from Meteor Methods
SimpleSchema.defineValidationErrorTransform(error => {
const ddpError = new Meteor.Error(error.message);
ddpError.error = 'validation-error';
ddpError.details = error.details;
return ddpError;
});
});
import SimpleSchema from "simpl-schema";
import { Meteor } from "meteor/meteor";
// This is needed so that it throws a Meteor.Error as `check()` would do
// when we call schema.validate() in a Meteor method.
// https://github.com/aldeed/node-simple-schema/#customize-the-error-that-is-thrown
SimpleSchema.defineValidationErrorTransform((error) => {
const ddpError = new Meteor.Error(error.message);
ddpError.error = "validation-error";
ddpError.details = error.details;
return ddpError;
});
import { Meteor } from 'meteor/meteor';
import SimpleSchema from 'simpl-schema';
SimpleSchema.defineValidationErrorTransform(e => (
new Meteor.Error(400, e.message)
));
import SimpleSchema from 'simpl-schema';
//provides a reason for mdg validated method error throw to notify user from error.message generated by simpleSchema
SimpleSchema.defineValidationErrorTransform(error => {
const ddpError = new Meteor.Error(error.message);
ddpError.error = 'validation-error';
ddpError.details = error.details;
ddpError.reason = error.details.reduce((a,x)=>a+x.message+". ", "")
return ddpError;
});
//methods
import '/imports/api/users/methods'
import '/imports/api/coins/methods.js'
import '/imports/api/miscellaneous/methods'
import '/imports/api/features/methods'
import '/imports/api/redflags/methods'
import '/imports/api/exchanges/methods'
import '/imports/api/coins/methods'
import '/imports/api/miscellaneous/mime'