From e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d Mon Sep 17 00:00:00 2001 From: Piotr Russ Date: Mon, 16 Nov 2020 00:10:28 +0100 Subject: api, login, auth --- node_modules/mongoose/tools/auth.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 node_modules/mongoose/tools/auth.js (limited to 'node_modules/mongoose/tools/auth.js') diff --git a/node_modules/mongoose/tools/auth.js b/node_modules/mongoose/tools/auth.js new file mode 100644 index 0000000..7cfaf86 --- /dev/null +++ b/node_modules/mongoose/tools/auth.js @@ -0,0 +1,30 @@ +'use strict'; + +const Server = require('mongodb-topology-manager').Server; +const co = require('co'); +const mongodb = require('mongodb'); + +co(function*() { + // Create new instance + const server = new Server('mongod', { + auth: null, + dbpath: '/data/db/27017' + }); + + // Purge the directory + yield server.purge(); + + // Start process + yield server.start(); + + const db = yield mongodb.MongoClient.connect('mongodb://localhost:27017/admin'); + + yield db.addUser('passwordIsTaco', 'taco', { + roles: ['dbOwner'] + }); + + console.log('done'); +}).catch(error => { + console.error(error); + process.exit(-1); +}); -- cgit v1.2.3