Skip to content

Instantly share code, notes, and snippets.

Avatar

Emilio Rios emilioriosvz

View GitHub Profile
@emilioriosvz
emilioriosvz / mongoose-connection.js
Created Apr 4, 2018
connect with mongoose using async/await
View mongoose-connection.js
const mongoose = require('mongoose')
mongoose.Promise = Promise
mongoose.connection.on('connected', () => {
console.log('Connection Established')
})
mongoose.connection.on('reconnected', () => {
console.log('Connection Reestablished')
View rabbitasyncawait.js
var amqp = require('amqplib')
var open = require('amqplib').connect('amqp://localhost');
const connect = (url = 'amqp://localhost') => {
return new Promise((resolve, reject) => {
amqp.connect(url)
.then(conn => resolve(conn))
.catch(err => reject(err))
})