How to use uniqid - 10 common examples

To help you get started, we’ve selected a few uniqid 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 peterjoseph / Reeve / server / orchestrator / authentication.js View on Github external
export async function generateUserEmailValidationCode(userId, clientId, transaction) {
	// Create unique validation code for userId
	const code = uniqid();

	// Store validation code in table
	await models().emailVerificationCode.create(
		{
			verificationCode: code,
			activated: false,
			userId: userId,
			clientId: clientId,
			gracePeriod: 2
		},
		{ transaction: transaction }
	);

	return code;
}
github webiny / webiny-js / packages / cli / backup / functions / fileHandlers / uploadRequest.js View on Github external
if (!type) {
        return respondWithError(`File "type" missing.`);
    }

    const contentType = mime.lookup(name);
    if (!contentType) {
        return respondWithError(`File's content type could not be resolved.`);
    }

    if (contentType !== type) {
        return respondWithError(`Detected and received file types don't match.`);
    }

    let key = sanitizeFilename(name);
    if (key) {
        key = uniqueId() + "_" + key;
    }

    // Replace all whitespace.
    key = key.replace(/\s/g, "");

    return respond({
        code: "FILE_UPLOAD_SUCCESS",
        data: {
            file: {
                name: key,
                src: "/files/" + key,
                type: contentType,
                size
            },
            s3: {
                url: "/files/upload",
github OpenSprites / OpenSprites-next / server / main.js View on Github external
app.get('/join', nocache, async function(req, res) {
  // if already signed in, skip
  if(req.session.user)
    res.redirect(req.query.r || '/')

  req.session.joinCode = req.session.joinCode || uniqid()

  res.render('join', {
    user: req.session.user,
    title: 'Join',

    code: req.session.joinCode,
    fail: req.session.joinFailWhy,
    already: req.session.join || {},
    project: signupProjectId != null,
    csrfToken: req.csrfToken()
  })

  delete req.session.joinFailWhy
})
github JustFly1984 / react-google-maps-api / packages / react-google-maps-api-gatsby-example / src / components / google-maps.js View on Github external
import SectionShapes from './section-shapes'
import SectionDrawing from './section-drawing'
import SectionBicycling from './section-bicycling'
import SectionTransit from './section-transit'
import SectionGround from './section-ground'
import SectionOptions from './section-options'
import SectionOverlayView from './section-overlay-view'
import SectionSearchbox from './section-searchbox'

import styles from './styles.module.css'

const Loading = <div>

const googleMapsLibraries = ['drawing', 'visualization', 'places']

const loaderId = uniqid('loader-')

const onLoad = () =&gt; console.log('script loaded')

const onError = err =&gt; console.log('onError: ', err)

const GoogleMaps = ({ googleMapsApiKey, language }) =&gt; (
  </div>
github ddmng / fontah / src / fx / effects.js View on Github external
const uniqId = (props, dispatch) => {
    if (props.token) {
        console.log("using params: ", props.token)
        dispatch(props.action, props.token)
    } else {
        console.log("generating uniqid")
        const p = process("#")
        window.location = window.location + p
        dispatch(props.action, p)
    }
}
github TeselaGen / openVectorEditor / src / selectors / translationsSelector.js View on Github external
...translationSearchMatches.reduce((acc, match) => {
      if (!match) return acc;
      const id = match.id || uuid();
      acc[id] = {
        ...match,
        id,
        translationType: "AA Search Match",
        isOrf: true, //pass isOrf = true here in order to not have it show up in the properties window
        forward: !match.bottomStrand
      };
      return acc;
    }, {}),
    ...reduce(
github dsheiko / puppetry / src / reducer / reducers.jsx View on Github external
entities = Object.values( tests ).reduce( ( carry, test ) => {
              if ( position.before && position.before === test.id ) {
                const gid = id || uniqid();
                carry[ gid ] = { ...testDefaultState( gid ), ...options, commands: {}};
              }
              carry[ test.id ] = test;
              if ( position.after && position.after === test.id ) {
                const gid = id || uniqid();
                carry[ gid ] = { ...testDefaultState( gid ), ...options, commands: {}};
              }
              return carry;
            }, {});
github bigfanjs / react-titles / src / Title6.js View on Github external
constructor(props) {
        super(props);

        const { text1, text2, open } = this.props;

        this.texts = [];

        this.state = {
            scales: [0, 0],
            gaps: [0, 0],
            open,
            close: !open,
            texts: [text1, text2]
        };

        this.id = uniqid();

        this.size = this.props.size;
        this.forceClose = this.props.forceClose || false;
        this.center = this.size / 2;
        this.strokeWidth = 2;
        this.offset = 7.5;
        this.dasharray = 20;

        this.isFirefox = typeof InstallTrigger !== "undefined";
    }
github dsheiko / puppetry / src / reducer / suite / target.js View on Github external
const entities = Object.values( targets ).reduce( ( carry, target ) => {
      if ( position.before && position.before === target.id ) {
        const gid = id || uniqid();
        carry[ gid ] = { ...targetDefaultState( gid ), ...options };
      }
      carry[ target.id ] = target;
      if ( position.after && position.after === target.id ) {
        const gid = id || uniqid();
        carry[ gid ] = { ...targetDefaultState( gid ), ...options };
      }
      return carry;
    }, {});
github Angarsk8 / Loopa-News / client / src / store / modules / posts.js View on Github external
.then((errorJSON) => {
          dispatch('addAlert', {
            id: uniqueId('alert_'),
            type: 'danger',
            message: errorJSON.message
          })
        })
      })

uniqid

Unique ID Generator

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis

Popular uniqid functions