How to use the shortid.characters function in shortid

To help you get started, we’ve selected a few shortid 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 Restuta / rcn.io / src / shared / _packages / events-core / gen-event-id.js View on Github external
/*
generate id manually by hitting
https://rcn.io/admin/create-event-id
*/

const slugify = require('shared/utils/slugify')
const shortid = require('shortid')
// custom alphabet, since by default it includes "-" which we are using as a separator as well
// must include 64 distinct characters
shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$')

//so we don't end-up with crazy long URLs, 100 is pessimistic for really long event names
const MAX_SLUG_LENGTH = 100

/**
 * Creates just a prefix of the event id without unique id part
 * @param {[type]} eventYear Yeah this even is taking place at
 * @param {[type]} eventName Name of the event
 * @param {[type]} shortSegmentName Typically used to improve event identificaiton
 * by just looking at it id, for example for NCNCA it would be "ncnca"
 * @returns {[type]} String
 */
const createEventIdPrefix = (eventYear, eventName, shortSegmentName) =>
  shortSegmentName
    ? `evt-${shortSegmentName}-${eventYear}-${slugify(eventName, MAX_SLUG_LENGTH)}`
    : `evt-${eventYear}-${slugify(eventName, MAX_SLUG_LENGTH)}`
github sirceljm / aws-lambda-blog / lambdas / src / admin / upload_image.js View on Github external
// uploadImage
var co = require('co');
var shortid = require('shortid');
shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$@');

var imageSize = require('image-size');
var Jimp = require("jimp");

var AWS = require('aws-sdk');
var docClient = new AWS.DynamoDB.DocumentClient();
var s3 = new AWS.S3({
    signatureVersion: 'v4'
});

var auth = require('../../lib/auth.js');
var dynamoObjects = require('../../lib/dynamoObjects.js');

exports.handler = (event, context, callback) => {
    // STAGE VARIABLES FROM API GATEWAY
    var stage = event.stage;
github jsonmvc / jsonmvc / src / views.js View on Github external
const Vue = require('vue/dist/vue.common.js')
const Emitter = require('events').EventEmitter
const most = require('most')
const shortid = require('shortid')
const PROP_REGEX = /<([a-z]+)>/g
const _ = require('lodash')

shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%^')

function updateInstanceData(db, schema, props, data, self, prop, val) {

  // Unsubscribe all listeners for this prop
  props.schema.subscribes[prop].forEach(y => y())
  props.schema.subscribes[prop] = []

  // For all the paths that are impacted by this prop
  props.schema.tokens[prop].props.forEach(x => {
    let path = getPath(schema, props, self, x)

    let listener = createDataListener(db, path, data, x)

    props.schema.subscribes[prop].push(listener)
  })
github soajs / soajs.dashboard / utils / drivers / git / github / helper.js View on Github external
"use strict";

var request = require("request");
var fs = require("fs");
var mkdirp = require("mkdirp");
var rimraf = require("rimraf");

var config = require("../../../../config.js");

var shortid = require("shortid");
shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_');

var gitApihub = require("github");
var github = new gitApihub({
	version: config.gitAccounts.github.apiVersion,
	debug: false,
	protocol: config.gitAccounts.github.protocol,
	host: config.gitAccounts.github.domainName,
	timeout: config.gitAccounts.github.timeout,
	headers: {
		'user-agent': config.gitAccounts.github.userAgent,
		'Cache-Control': 'no-cache'
	}
});

function checkIfError (error, options, cb, callback) {
	if (error) {
github soajs / soajs.dashboard / lib / cloud / deploy / index.js View on Github external
'use strict';
const fs = require("fs");
const async = require("async");
const shortid = require('shortid');
let vmModule = require("../vm/index.js");
const utils = require("../../../utils/utils.js");
const soajsUtils = require("soajs.core.libs").utils;
const soajsLib = require("soajs.core.libs");
shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_');
let dbModel = "mongo";
const colls = {
	env: 'environment',
	git: 'git_accounts',
	services: 'services',
	daemons: 'daemons',
	staticContent: 'staticContent',
	catalog: 'catalogs',
	cicd: 'cicd',
	infra: 'infra',
	resources: 'resources'
};

const helpers = require("./helper.js");

let BL = {
github awslabs / aws-data-lake-solution / source / api / services / package / lib / content-package.js View on Github external
if (settings.Items.length > 0) {
                    for (let i = 0; i < settings.Items.length; i++) {
                        let _mdata = null;
                        if (_body.metadata) {
                            _mdata = _.find(_body.metadata, function(val) {
                                return val.tag == settings.Items[i].setting.tag;
                            });
                        }

                        if (!_mdata && settings.Items[i].setting.governance === 'Required') {
                            return cb({code: 400, message: `The required metadata ${settings.Items[i].setting.tag} is missing`}, null);
                        }
                    }
                }

                shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$@');
                let _package = _body.package;
                let _newpackage = {
                    package_id: shortid.generate(),
                    created_at: moment.utc().format(),
                    updated_at: moment.utc().format(),
                    owner: ticket.userid,
                    name: _package.name.substring(0, 100).trim(),
                    description: _package.description.substring(0, 1000).trim(),
                    deleted: false
                };

                if ('groups' in _package && _package.groups.length > 0) {
                    _newpackage.groups = _package.groups;
                }

                let _schemaCheck = v.validate(_newpackage, packageSchema);
github lnshi / node-cayley / lib / util / CommonImport.js View on Github external
'use strict';

const winston = require('winston');

const shortid = require('shortid');
shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$ಠ');

/*
 * 'npm' logging levels:
 *   { error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5 }
 *
 *  RFC5424 'syslog' levels:
 *   { emerg: 0, alert: 1, crit: 2, error: 3, warning: 4, notice: 5, info: 6, debug: 7 }
 */
winston.setLevels(winston.config.npm.levels);

module.exports = {
  logger: winston,
  shortid: shortid,
  
  fs: require('fs'),
  path: require('path'),
github soajs / soajs.dashboard / lib / environment / helper.js View on Github external
generateRandomString: function(){
		shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_');
		return shortid.generate();
	},
github soajs / soajs.dashboard / utils / drivers / git / helpers / github.js View on Github external
"use strict";

var request = require("request");
var fs = require("fs");
var mkdirp = require("mkdirp");
var rimraf = require("rimraf");

var config = require("../../../../config.js");

var shortid = require("shortid");
shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_');

var gitApihub = require("github");
var github = new gitApihub({
	version: config.gitAccounts.github.apiVersion,
	debug: false,
	protocol: config.gitAccounts.github.protocol,
	host: config.gitAccounts.github.domainName,
	timeout: config.gitAccounts.github.timeout,
	headers: {
		'user-agent': config.gitAccounts.github.userAgent
	}
});

function checkIfError (error, options, cb, callback) {
	if (error) {
		if (options && options.code) {
github callmekory / nezuko / src / subprocesses / webServer / index.ts View on Github external
public async run() {
    shortid.characters('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-@')
    /**
     * example API usage
     *  {
     *      "command": " "
     *  }
     */
    const { webServerPort, ownerID } = this.client.config
    const { Log, generalConfig } = this.client

    const checkApiKey = async (req, res) => {
      const db = await generalConfig.findOne({ where: { id: ownerID } })
      const config = JSON.parse(db.dataValues.config)
      const { apiKey } = config.webUI

      if (!req.body.apiKey) {
        Log.info(

shortid

Amazingly short non-sequential url-friendly unique id generator.

MIT
Latest version published 4 years ago

Package Health Score

52 / 100
Full package analysis