How to use nano - 7 common examples

To help you get started, we’ve selected a few nano 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 NemProject / NanoWallet / tests / specs / namespaceModule.spec.js View on Github external
let scope = $rootScope.$new();
        createDummyWalletContextTestnet(Wallet);
        let ctrl = $controller('NamespacesCtrl', {
            $scope: scope
        });
        ctrl.namespaceOwned["nano.test.third"] = {
            "owner": "TAF7BPDV22HCFNRJEWOGLRKBYQF65GBOLQPI5GGO",
            "fqn": "nano.test.third",
            "height": 547741
        }
        let NSarray = $filter('objValues')(ctrl.namespaceOwned);

        // Act & Assert
        expect(ctrl.isNotLevel3(NSarray[0])).toBe(true);
        expect(ctrl.isNotLevel3(NSarray[1])).toBe(false);
        delete ctrl.namespaceOwned["nano.test.third"];
    });
github algolia / npm-search / src / npm / index.js View on Github external
import got from 'got';
import nano from 'nano';
import chunk from 'lodash/chunk.js';
import numeral from 'numeral';

import config from '../config.js';
import datadog from '../datadog.js';
import log from '../log.js';

const registry = nano({
  url: config.npmRegistryEndpoint,
});
const db = registry.use(config.npmRegistryDBName);

// Default request options
const defaultOptions = {
  include_docs: true, // eslint-disable-line camelcase
  conflicts: false,
  attachments: false,
};

/**
 * Find all packages in registry
 *
 * @param {object} options Options param
 */
github sevcsik / node-couchdb-model / restapi-demo / restapidemo.js View on Github external
console.log('Configuration (change them with environment variables): ');
console.log('\tHOST: \t\t\t', HOST);
console.log('\tPORT: \t\t\t', PORT);
console.log('\tCOUCHDB_BASE_URL: \t', COUCHDB_BASE_URL);
console.log('\tCOUCHDB_DB_NAME: \t', COUCHDB_DB_NAME);

nano = nano(COUCHDB_BASE_URL);

if (!COUCHDB_BASE_URL) {
	throw new Error('Environment variable COUCHDB_BASE_URL is not set!');
}

var server;

console.log('Destroying database ' + COUCHDB_DB_NAME);
Q.ninvoke(nano.db, 'destroy', COUCHDB_DB_NAME).
	then(function() {}, function() {}).
	then(function() {

	console.log('Creating database ' + COUCHDB_DB_NAME);
	return Q.ninvoke(nano.db, 'create', COUCHDB_DB_NAME);
}).then(function() {
	var model = new couchDBModel(nano.use(COUCHDB_DB_NAME), {
		restapi: {
			index: true,
			byID: true,
			save: true
		}			
	});

	console.log('Bound REST API to request event');
	server.on('request', model.onRequest);
github sevcsik / node-couchdb-model / restapi-demo / restapidemo.js View on Github external
process.on('SIGTERM', function() {
	console.log('Destroying database ' + COCUDB_DB_NAME);
	nano.db.destroy(COUCHDB_DB_NAME, function(error) {
		if (error) {
			throw error;
		}

		server.close();
		console.log('Bye.');
	});
});
github sballesteros / linked-data-registry / queue / worker.js View on Github external
ssl: process.env['COUCH_SSL'],
  host: process.env['COUCH_HOST'],
  port: process.env['COUCH_PORT'],
  registry: (process.env['REGISTRY_DB_NAME'] || 'registry')
};

var sqsQueueName = process.env['QUEUE_NAME'];

var admin = { username: process.env['COUCH_USER'], password: process.env['COUCH_PASS'] };

var rootCouch = util.format('%s://%s:%s', (couch.ssl == 1) ? 'https': 'http', couch.host, couch.port) //https is optional so that we can play localy without SSL. That being said, in production it should be 1!
  , rootCouchAdmin = util.format('%s://%s:%s@%s:%d', (couch.ssl == 1) ? 'https': 'http', admin.username, admin.password, couch.host, couch.port)
  , rootCouchRegistry = util.format('%s://%s:%s/%s', (couch.ssl == 1) ? 'https': 'http', couch.host, couch.port, couch.registry);

var nano = require('nano')(rootCouchAdmin); //connect as admin
var registry = nano.db.use(couch.registry)

var sqs = new AWS.SQS();

s3.createBucket(function(err, data) {
  if(err) throw err;
  console.log('S3 bucket (%s) OK', bucket);

  sqs.getQueueUrl({QueueName: sqsQueueName}, function(err, data){
    if(err) throw err;

    var queueUrl = data.QueueUrl;

    if(!queueUrl.length) throw new Error('could not get queue');

    console.log('queue "%s" at: %s', sqsQueueName, queueUrl);
github sevcsik / node-couchdb-model / restapi-demo / restapidemo.js View on Github external
}).then(function() {
	var model = new couchDBModel(nano.use(COUCHDB_DB_NAME), {
		restapi: {
			index: true,
			byID: true,
			save: true
		}			
	});

	console.log('Bound REST API to request event');
	server.on('request', model.onRequest);

}, function(error) {
	console.error(error);
github dbankier / nano / example / app / controllers / index.js View on Github external
setTimeout(function() {
  $model.person.first = "First";
  nano.apply();
},1000);

nano

The official CouchDB client for Node.js

Apache-2.0
Latest version published 4 months ago

Package Health Score

82 / 100
Full package analysis