How to use the node-persist.initSync 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 KhaosT / HAP-NodeJS / src / CameraCore.ts View on Github external
import storage from 'node-persist';

import { Accessory, AccessoryEventTypes, Camera, Categories, uuid, VoidCallback } from './';

console.log("HAP-NodeJS starting...");

// Initialize our storage system
storage.initSync();

// Start by creating our Bridge which will host all loaded Accessories
var cameraAccessory = new Accessory('Node Camera', uuid.generate("Node Camera"));

var cameraSource = new Camera();

cameraAccessory.configureCameraSource(cameraSource);

cameraAccessory.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
  console.log("Node Camera identify");
  callback(); // success
});

// Publish the camera on the local network.
cameraAccessory.publish({
  username: "EC:22:3D:D3:CE:CE",
github KhaosT / HAP-NodeJS / index.js View on Github external
function init(storagePath) {
  // initialize our underlying storage system, passing on the directory if needed
  if (typeof storagePath !== 'undefined')
    storage.initSync({ dir: storagePath });
  else
    storage.initSync(); // use whatever is default
}
github KhaosT / HAP-NodeJS / src / BridgedCore.ts View on Github external
import path from 'path';

import storage from 'node-persist';

import { Accessory, AccessoryEventTypes, AccessoryLoader, Bridge, Categories, uuid, VoidCallback } from './';

console.log("HAP-NodeJS starting...");

// Initialize our storage system
storage.initSync();

// Start by creating our Bridge which will host all loaded Accessories
const bridge = new Bridge('Node Bridge', uuid.generate("Node Bridge"));

// Listen for bridge identification event
bridge.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {
  console.log("Node Bridge identify");
  callback(); // success
});

// Load up all accessories in the /accessories folder
var dir = path.join(__dirname, "accessories");
var accessories = AccessoryLoader.loadDirectory(dir);

// Add them all to the bridge
accessories.forEach((accessory: Accessory) => {
github KhaosT / HAP-NodeJS / src / Core.ts View on Github external
import path from 'path';

import storage from 'node-persist';

import { AccessoryLoader } from './';

console.log("HAP-NodeJS starting...");

// Initialize our storage system
storage.initSync();

// Our Accessories will each have their own HAP server; we will assign ports sequentially
var targetPort = 51826;

// Load up all accessories in the /accessories folder
var dir = path.join(__dirname, "accessories");
var accessories = AccessoryLoader.loadDirectory(dir);

// Publish them all separately (as opposed to BridgedCore which publishes them behind a single Bridge accessory)
accessories.forEach((accessory) => {

  // To push Accessories separately, we'll need a few extra properties
  // @ts-ignore
  if (!accessory.username)
    throw new Error("Username not found on accessory '" + accessory.displayName +
                    "'. Core.js requires all accessories to define a unique 'username' property.");
github fjn2 / one4all / server / classes / Server.js View on Github external
constructor(roomName) {
    this.roomName = roomName;
    // to store the playlist
    Winston.debug('Reading from', `./playlistStoredData_${this.roomName}`);
    storage.initSync({
      dir: `./playlistStoredData_${this.roomName}`
    });
    Winston.debug('Reading finish');
    this.songPlayer = new SongPlayer();


    this.clientActions = {
      serverTime: () => new Date(),
      currentTrack: () => this.playlist.getCurrentSong(),
      timeCurrentTrack: () => ({
        trackTime: this.songPlayer.getCurrentTime(),
        playing: this.songPlayer.playing,
        serverTime: new Date()
      }),
      addSong: data => (
        Promise.resolve(data.url).then((songUrl) => {
github nitaybz / homebridge-tado-ac / index.js View on Github external
this.anyoneSensor = config['anyoneSensor'] === false ? false : true
    this.statePollingInterval = (config['statePollingInterval'] * 1000) || false
    this.debug = config['debug']
    // special settings for zones
    this.manualControlSwitch = config['manualControl'] || config['manualControlSwitch'] || false
    this.disableHumiditySensor = config['disableHumiditySensor'] || false
    this.extraHumiditySensor = config['extraHumiditySensor'] || false
    this.autoFanOnly = config['autoOnly'] || config['autoFanOnly'] || false
    this.disableFan = config['disableFan'] || false
    this.forceThermostat = config['forceThermostat'] || false
    this.cachedSettingsOnly = config['cachedSettingsOnly'] || false //new
    this.historyStorage = config['historyStorage'] || false //new
    this.forceHeaterCooler = config['forceHeaterCooler'] || false //new
    this.disableAcAccessory = config['disableAcAccessory'] || false //new

    storage.initSync({
        dir: HomebridgeAPI.user.persistPath()
    })

    this.storeToken = tadoHelpers.storeToken.bind(this)
    tadoApi.getToken = tadoApi.getToken.bind(this)

    this.tadoSettings = storage.getItem("tadoCachedSettings")

    //Get Token
    if (this.debug) this.log('Getting Token')

    tadoApi.getToken(this.username, this.password, this.storeToken)
    setInterval(() => {
        if (this.debug) this.log('Getting Token')
        tadoApi.getToken(this.username, this.password, this.storeToken)
    }, 500000)
github GoogleChromeLabs / web-push-testing-service / src / cli / index.js View on Github external
constructor() {
    storage.initSync();

    this._debugMode = false;

    logHelper.setLogFile('./cli.log');
  }
github Appyx / AccessoryServer / Server / Data / ConfigurationHandler.ts View on Github external
function init() {
        storage.initSync();
        loadAccessories();
    }
github mistval / kotoba / core / persistence.js View on Github external
init(options) {
    storage.initSync(options);
    this.initialized_ = true;
  }
github owenconti / livecodingtv-bot / utils / Brain.js View on Github external
static start( directory ) {
		brain.initSync({
			dir: directory
		});
	}