How to use the cuid function in cuid

To help you get started, we’ve selected a few cuid 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 jirokun / survey-designer-js / lib / editor / components / editors / FinisherEditor.js View on Github external
constructor(props) {
    super(props);
    // tinymceがかぶらないようにするためにcuidを生成
    this.cuid = cuid();
  }
github MoonMail / MoonMail / lists-microservice / src / domain / ListModel.js View on Github external
static get createSchema() {
    return Joi.object({
      userId: Joi.string().required(),
      id: Joi.string().default(cuid()),
      createdAt: Joi.number().default(moment().unix()),
      importStatus: Joi.object(),
      isDelete: Joi.string().default(false.toString()),
      name: Joi.string().required(),
      // Not sure if this should be required
      senderId: Joi.string()
    });
  }
github MoonMail / MoonMail / api / emailTemplates / createTemplate / action.js View on Github external
decrypt(event.authToken).then((decoded) => {
    if (event.template) {
      const template = event.template;
      template.userId = decoded.sub;
      template.id = cuid();
      handleScreenshot(template)
        .then(templateToSave => EmailTemplate.save(templateToSave))
        .then(() => cb(null, template))
        .catch((e) => {
          debug(e);
          return cb(ApiErrors.response(e));
        });
    } else {
      return cb(ApiErrors.response('No template specified'));
    }
  }).catch(err => cb(ApiErrors.response(err), null));
}
github MoonMail / MoonMail / events / automations / lib / trigger_automations_service.js View on Github external
static _buildCommonEmailParams(sender, automationAction) {
    logger().debug('_buildCommonEmailParams', JSON.stringify({ automationAction, sender }));
    return {
      id: cuid(),
      userId: automationAction.userId,
      sender,
      status: 'scheduled',
      scheduledAt: moment().unix() + (automationAction.delay || 0),
      automationId: automationAction.automationId,
      automationActionId: automationAction.id
    };
  }
github bradfordlemley / stated-library / examples / todoapp / src / state / TodoLib.ts View on Github external
export const makeTodo = (text: string, completed?: boolean) => ({
  id: cuid(),
  text,
  completed: Boolean(completed),
});
github MoonMail / MoonMail / api / automations / createAutomation / action.js View on Github external
function createAutomation(userId, event) {
  const baseAutomation = { id: cuid(), userId, status: 'paused' };
  const automation = Object.assign({}, event.automation, baseAutomation);
  const checkParams = paramsChecker(['userId', 'listId', 'senderId', 'id']);
  return checkParams(automation)
    .then(validAutomation => Automation.save(validAutomation))
    .then(() => automation);
}
github MoonMail / MoonMail / api / campaigns / createCampaign / action.js View on Github external
decrypt(event.authToken).then((decoded) => {
    if(decoded.sub === 'google-oauth2|113947278021199221588') throw 'Sorry, the demo account is not allowed to perform this action' //demo account
    if (event.campaign) {
      let campaign = event.campaign;
      campaign.userId = decoded.sub;
      campaign.id = cuid();
      campaign.status = 'draft';
      Campaign.save(campaign).then(() => {
        return cb(null, campaign);
      }).catch(e => {
        debug(e);
        return cb(ApiErrors.response(e));
      });
    } else {
      return cb(ApiErrors.response('No campaign specified'));
    }
  })
  .catch(err => cb(ApiErrors.response(err), null));
github jirokun / survey-designer-js / lib / editor / components / question_editors / parts / ValueEditorPart.js View on Github external
constructor(props) {
    super(props);

    this.cuid = cuid();
    const { value } = props;
    this.state = {
      mode: S(value).isEmpty() || S(value).isNumeric() ? 'fixedValue' : 'answerValue',
    };
  }
github kbuechl / react-uikit-components / docs / src / notify-doc.jsx View on Github external
updateState (message) {
    this.setState({
      messages: [
        ...this.state.messages,
        {
          message: 'Message...',
          kitid:  cuid(),
          timeout: 3000,
          animate: {
            in : kitid => this.handleNotifyIn(kitid),
            out: kitid => this.handleNotifyOut(kitid)
          },
          onClick: e => this.handleClose(e),
          ...message,
        }
      ]
    });
  }

cuid

Collision-resistant ids optimized for horizontal scaling and performance. For node and browsers.

MIT
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis