How to use the fibers function in fibers

To help you get started, we’ve selected a few fibers 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 jcoreio / crater / src / server / createSSR.js View on Github external
function renderApp(res: ServerResponse, store: Store, assets?: Object, renderProps?: Object) {
  Fiber(() => Meteor.bindEnvironment(() => {
    const location = renderProps && renderProps.location && renderProps.location.pathname || '/'
    // Needed so some components can render based on location
    store.dispatch(push(location))
    const htmlStream = renderToStaticMarkup(
      
    )
    res.write('')
    htmlStream.pipe(res, {end: false})
    htmlStream.on('end', (): void => res.end())
  })()).run()
github RocketChat / Rocket.Chat / app / meteor-accounts-saml / server / saml_server.js View on Github external
}

						const logOutUser = function(samlInfo) {
							const loggedOutUser = Meteor.users.find({
								$or: [
									{ 'services.saml.nameID': samlInfo.nameID },
									{ 'services.saml.idpSession': samlInfo.idpSession },
								],
							}).fetch();

							if (loggedOutUser.length === 1) {
								logoutRemoveTokens(loggedOutUser[0]._id);
							}
						};

						fiber(function() {
							logOutUser(result);
						}).run();

						const { response } = _saml.generateLogoutResponse({
							nameID: result.nameID,
							sessionIndex: result.idpSession,
						});

						_saml.logoutResponseToUrl(response, function(err, url) {
							if (err) {
								console.error(err);
								throw new Meteor.Error('Unable to generate SAML logout Response Url');
							}

							res.writeHead(302, {
								Location: url,
github sozialhelden / accessibility-cloud / server / json-api / json-api.js View on Github external
function handle() {
    Fiber(() => handleJSONRequest(req, res, next))
      .run();
  }
github xcv58 / meteor-collectionapi / meteor / lib / request-listener.js View on Github external
delete() {
    if (!this._requestPath.collectionId) {
      return this._notFoundResponse('Missing _id');
    }

    return fibers(() => {
      try {
        const returnObject = getReturnObject();

        if (!this._beforeHandling(
          'DELETE',
          this._requestCollection.findOne(this._requestPath.collectionId),
          this._requestPath,
          returnObject
        )) {
          return this._rejectedResponse('Could not delete that object.');
        }

        if (this._handleReturnObject('DELETE', returnObject)) {
          return true;
        }
github TheBrainFamily / chimpy / src / lib / utils / fiberize.js View on Github external
return function () {
    const self = this;
    Fiber(function () {
      fn.call(self);
    }).run();
  };
}
github lmachens / meteor-apm-server / apm / server / alertsman / server / messenger.js View on Github external
let retryPromise = promiseRetry(retry => {
      try {
        Fiber(() => {
          return Email.send(mailOptions);
        }).run();
      } catch (error) {
        retry(error);
      }
    }, retryOptions);
github srtucker22 / glipchat / server / rest / auth-middleware.rest.js View on Github external
function(req, res, next) {
    Fiber(function() {
      const userId = getUserIdFromAuthToken(req.authToken);
      if (userId) {
        req.userId = userId;
      }

      next();
    }).run();
  };
github xcv58 / meteor-collectionapi / meteor / lib / request-listener.js View on Github external
return this._request.on('end', () => {
      fibers(() => {
        try {
          const obj = JSON.parse(requestData);

          const returnObject = getReturnObject();

          if (!this._beforeHandling(
            'PUT',
            this._requestCollection.findOne(this._requestPath.collectionId),
            obj,
            this._requestPath,
            returnObject
          )) {
            return this._rejectedResponse('Could not put that object.');
          }

          if (this._handleReturnObject('PUT', returnObject)) {
github sozialhelden / accessibility-cloud / both / api / sources / server / methods.js View on Github external
check(sourceId, String);
    check(options, Match.Optional({ skipGlobalStats: Match.Optional(Boolean), token: Match.Optional(String) }));
    const source = Sources.findOne(sourceId);
    if (!source) {
      throw new Meteor.Error(404, 'Not found');
    }
    if (!options || !options.token || options.token !== Meteor.settings.ddpClientToken) {
      if (!this.userId) {
        throw new Meteor.Error(401, 'Please log in first.');
      }
      if (!source.editableBy(this.userId)) {
        throw new Meteor.Error(402, 'Not authorized');
      }
    }
    this.unblock();
    Fiber(() => {
      source.generateAndSaveStats(options);
    }).run();
  },
});