How to use the meteor/meteor.Meteor.isServer function in meteor

To help you get started, we’ve selected a few meteor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github berkmancenter / question_tool / server / methods.tests.js View on Github external
/* eslint-env mocha  */
/* eslint-disable prefer-arrow-callback, func-names, camelcase */

import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { Accounts } from 'meteor/accounts-base';
import { assert } from 'chai';
import { resetDatabase } from 'meteor/xolvio:cleaner';
import { Instances, Questions, Answers, Votes } from '/lib/common.js';
import './methods.js';

if (Meteor.isServer) {
  describe('Methods', function () {
    const test_admin = {
      email: 'admin@admins.us',
      password: Random.hexString(10),
      profile: {
        name: 'Ms. Admin',
      },
    };

    const test_mod = {
      email: 'mod@mods.us',
      password: Random.hexString(10),
      profile: {
        name: 'Mod McMod',
      },
    };
github signmeup / signmeup / imports / startup / both / register-api.js View on Github external
import "/imports/api/locations/methods";

import "/imports/api/queues/methods";
import "/imports/api/queues/helpers";

import "/imports/api/sessions/methods";
import "/imports/api/sessions/helpers";

import "/imports/api/tickets/methods";
import "/imports/api/tickets/helpers";

import "/imports/api/users/users";
import "/imports/api/users/helpers";
import "/imports/api/users/methods";

if (Meteor.isServer) {
  /* eslint-disable global-require */
  require("/imports/api/announcements/server/publications.js");
  require("/imports/api/courses/server/publications.js");
  require("/imports/api/locations/server/publications.js");
  require("/imports/api/queues/server/publications.js");
  require("/imports/api/sessions/server/publications.js");
  require("/imports/api/tickets/server/publications.js");
  require("/imports/api/users/server/publications.js");
  /* eslint-enable global-require */
}
github bigbluebutton / bigbluebutton / bigbluebutton-html5 / imports / api / polls / index.js View on Github external
import { Meteor } from 'meteor/meteor';

const Polls = new Mongo.Collection('polls2x');

if (Meteor.isServer) {
  // We can have just one active poll per meeting
  // makes no sense to index it by anything other than meetingId

  Polls._ensureIndex({ meetingId: 1 });
}

export default Polls;
github CounteractIO / counteract / meteor / main.js View on Github external
tweetstream.push(tweet)
            }
        })
        console.log(tweetstream)
    });
    Template.body.helpers({
        main: function() {
            if (ActiveRoute.path('/')) return 'home'
            else return 'vis'
        },
        tweet: function() {
            return tweet.find().fetch()
        }
    })
}
if (Meteor.isServer) {
    tweets.allow({
        insert: function() {
            return true;
        },
        update: function() {
            return true;
        },
        remove: function() {
            return true;
        }
    });
    if (tweets.find().count() == 0) {
        tweets.insert({ "name": "ultybs scjhkv", "handle": "zqwvteop", "date": 1470715200000, "num_retweets": 28, "location": { "type": "Point", "coordinates": [-168.11289992853986, 40.92125425551876] }, "content": "miubkotohagiqjurbnydwchbgigpzznkbhlccvvwfbgmwtzebwbzmqysovcjxzburhfmeckrvyomkfmnkeoirnpotmbzydnxcigvkmukornvgiewyhkozuirqshklorwpjssoblztuvr", "risk_level": 86 });
    }
    Meteor.publish("tweet", function() {
        return tweets.find();
github nrkno / tv-automation-server-core / meteor / lib / collections / PieceInstances.ts View on Github external
Meteor.startup(() => {
	if (Meteor.isServer) {
		PieceInstances._ensureIndex({
			rundownId: 1,
			partInstanceId: 1
		})
	}
})
github thm-projects / arsnova-flashcards / imports / api / export.js View on Github external
function exportCards(cardset_id, isCardsExport = true, exportWithIds = false) {
	if (Meteor.isServer) {
		let owner = Cardsets.findOne(cardset_id).owner;
		var cards = [];
		if (exportWithIds) {
			cards = Cards.find({
				cardset_id: cardset_id
			}, {
				fields: {
					'cardset_id': 0,
					'cardGroup': 0,
					'cardType': 0,
					'difficulty': 0
				}, sort: {
					'subject': 1,
					'front': 1
				}
			}).fetch();
github thm-projects / arsnova-flashcards / imports / api / colleges.js View on Github external
import {Meteor} from "meteor/meteor";

export const Colleges = new TAPi18n.Collection("colleges");

if (Meteor.isServer) {
	Meteor.publish("colleges", function () {
		return Colleges.find();
	});
}
github 4minitz / 4minitz / imports / collections / onlineusers_private.js View on Github external
import { Meteor } from 'meteor/meteor';
import { OnlineUsersSchema } from './onlineusers.schema';
import { check } from 'meteor/check';
import moment from 'moment/moment';

if (Meteor.isServer) {
    Meteor.publish('onlineUsersForRoute', function (route) {
        return OnlineUsersSchema.find({activeRoute: route});
    });
}

const checkRouteParamAndAuthorization = (route, userId) => {
    check(route, String);
    if (!userId) {
        throw new Meteor.Error('not-authorized');
    }
};

Meteor.methods({
    'onlineUsers.enterRoute'(route) {
        const userId = Meteor.userId();
        checkRouteParamAndAuthorization(route, userId);
github nrkno / tv-automation-server-core / meteor / lib / collections / Studios.ts View on Github external
Meteor.startup(() => {
	if (Meteor.isServer) {
		ObserveChangesForHash(Studios, '_rundownVersionHash', ['config'])
	}
})
github apendua / ddp-redux / example / backend / imports / api / implement.js View on Github external
const implement = (method, { mixins = [], onServer, ...options } = {}) => {
  const adjustedOptions = { ...options };
  const name = method.getName();
  if (onServer) {
    let func = () => {};
    if (Meteor.isServer) {
      func = onServer();
    }
    if (!func) {
      throw new Error(`Invalid method definition, check "onServer" for ${method.getName()}`);
    }
    if (options.run) {
      throw new Error('When "onServer" is provided, "run" is not allowed');
    }
    adjustedOptions.run = function (...args) {
      if (!this.userId) {
        throw new Meteor.Error(`${name}.notAllowed`, 'You must be logged in');
      }
      return func(this, ...args);
    };
  }
  return new ValidatedMethod({