How to use the node-persist.setItem function in node-persist

To help you get started, we’ve selected a few node-persist 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 sonatype-nexus-community / auditjs / src / Services / OssIndexRequestService.ts View on Github external
private async insertResponsesIntoCache(
    response: Array
  ) {
    // console.debug(`Preparing to cache ${response.length} coordinate responses`);

    for (let i = 0; i < response.length; i++) {
      await NodePersist.setItem(response[i].coordinates, response[i]);
    }

    // console.debug(`Done caching`);
    return response;
  }
github xyfir / accownt / server / lib / register / finish.ts View on Github external
export async function finishRegistration(jwt?: Accownt.JWT): Promise {
  if (jwt === null) throw 'Invalid or expired token';

  // Verify JWT's userId matches the userId that the JWT's email points to
  // This way only the most recent email verification JWT is valid since it
  // will point to the newest user
  const userId = await emailToId(jwt.email);
  if (userId != jwt.userId)
    throw 'This token has been invalidated by a newer one';

  // Verify user's email
  await storage.init(STORAGE);
  const user: Accownt.User = await storage.getItem(`user-${jwt.userId}`);
  user.verified = true;
  await storage.setItem(`user-${jwt.userId}`, user);

  return await signJWT(jwt.userId, jwt.email, JWT_EXPIRES_IN);
}
github macecchi / pebble-itunesify-remote / osx / app / index.js View on Github external
const port = 8080;
var server;


// Load preferences

storage.initSync();

if (typeof storage.getItem('activePlayer') === 'undefined') {
    storage.setItem('activePlayer', 'itunes');
}
var activePlayer = storage.getItem('activePlayer');
console.log("Starting with active player: " + activePlayer);

if (typeof storage.getItem('controlGlobalVolume') === 'undefined') {
    storage.setItem('controlGlobalVolume', true);
}
var controlGlobalVolume = storage.getItem('controlGlobalVolume');
console.log("Controls global volume: " + controlGlobalVolume);


// GUI

var localIP;

require('dns').lookup(require('os').hostname(), function (err, add, fam) {
  localIP = add;
	menu.insert(new gui.MenuItem({
	    label: 'Server running on ' + localIP,
	    enabled: false
	}), 0);
})
github funsocietyirc / MrNodeBot / bot.js View on Github external
async _initStorageSubSystem() {
        await storage.init();
        try {
            const tmpIgnore = await storage.getItem('ignored');
            this.Ignore = tmpIgnore || this.Ignore;
            const tmpAdmins = await storage.getItem('admins');
            if (tmpAdmins) {
                this.Admins = tmpAdmins;
            } else {
                this.Admins = [_.toLower(this.Config.owner.nick)];
                await storage.setItem('admins', this.Admins);
            }
        } catch (err) {
            logger.error('Error Loading the Persisted Assets'); // TODO Localize
            return;
        }
        logger.info(t('storage.initialized'));
    }
github xyfir / accownt / server / lib / login / normal.ts View on Github external
if (
    user.failedLogins >= 5 &&
    user.lastFailedLogin + 15 * 60 * 1000 > Date.now()
  )
    throw 'Too many failed logins; wait 15 minutes';

  // Check password
  const match = await bcrypt.compare(pass, user.password);
  if (!match) {
    // Reset failedLogins after 15 minutes
    if (user.lastFailedLogin + 15 * 60 * 1000 < Date.now())
      user.failedLogins = 0;

    user.failedLogins++;
    user.lastFailedLogin = Date.now();
    await storage.setItem(`user-${userId}`, user);
    throw `Email/password do not match (${user.failedLogins} failed logins)`;
  }

  // Check OTP
  if (user.totpSecret && !totp.verify({ secret: user.totpSecret, token: otp }))
    throw 'Invalid one-time password (2FA code)';

  return signJWT(userId, email, JWT_EXPIRES_IN);
}
github akhoury / nodebb-plugin-ubbmigrator / ubbmigrator.js View on Github external
_ouids.push(user._ouid);

						if (ui % 1000 == 0)
							logger.info('Prepared ' + ui + ' users so far.');

					} else {
						userData.skipped = user;
						users.slice(ui, 1);
						logger.warn('[!username] skipping user ' + user._username + ':' + user._email + ' _ouid: ' + user._ouid);
					}
				} else {
					logger.warn('[!_username | !_joindate | !_email] skipping user ' + user._username + ':' + user._email + ' _ouid: ' + user._ouid);
					userData.skipped = user;
					users.slice(ui, 1);
				}
				storage.setItem('u.' + user._ouid, userData);
			});
			logger.info('Preparing users done. normalized ' + kept + '/' + users.length);
github bcongdon / github-label-notify / utils / github.js View on Github external
}, function(err, res){
            if(err){
                throw(err)
            }
            storage.initSync();
            var dict = storage.getItem("github_issues")
            var new_issues = []
            dict = dict || {}
            for(var i = 0; i < res.length; i++){
                if(!(res[i].html_url in dict)){
                    new_issues.push(res[i])
                    dict[res[i].html_url] = true
                }
            }
            storage.setItem("github_issues", dict);
            callback(new_issues);
    });
}
github bcongdon / github-label-notify / utils / watch_list.js View on Github external
exports.data = function() {
  storage.initSync();
  if (!storage.getItem('watch_list')){
    storage.setItem('watch_list', []);
  }
  return storage.getItemSync('watch_list');
}
github mistval / kotoba / core / implementations / persistence_implementation.js View on Github external
function setData(key, value) {
  return storage.setItem(key, value);
}