Commit 22b2516d authored by ncastejon's avatar ncastejon
Browse files

Add amqplib dependency

parent b6cc1ebf
Pipeline #2527 passed with stages
in 1 minute and 38 seconds
......@@ -467,6 +467,18 @@
"integrity": "sha1-6GuBnGAs+IIa1jdBNpjx3sAhhHo=",
"dev": true
},
"amqplib": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/amqplib/-/amqplib-0.5.2.tgz",
"integrity": "sha512-l9mCs6LbydtHqRniRwYkKdqxVa6XMz3Vw1fh+2gJaaVgTM6Jk3o8RccAKWKtlhT1US5sWrFh+KKxsVUALURSIA==",
"requires": {
"bitsyntax": "~0.0.4",
"bluebird": "^3.4.6",
"buffer-more-ints": "0.0.2",
"readable-stream": "1.x >=1.1.9",
"safe-buffer": "^5.0.1"
}
},
"ansi-align": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz",
......@@ -1330,11 +1342,18 @@
"integrity": "sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg==",
"dev": true
},
"bitsyntax": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/bitsyntax/-/bitsyntax-0.0.4.tgz",
"integrity": "sha1-6xDMb4K4xJDj6FaY8H6D1G4MuoI=",
"requires": {
"buffer-more-ints": "0.0.2"
}
},
"bluebird": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.2.tgz",
"integrity": "sha512-dhHTWMI7kMx5whMQntl7Vr9C6BvV10lFXDAasnqnrMYhXVCzzk6IO9Fo2L75jXHT07WrOngL1WDXOp+yYS91Yg==",
"dev": true
"integrity": "sha512-dhHTWMI7kMx5whMQntl7Vr9C6BvV10lFXDAasnqnrMYhXVCzzk6IO9Fo2L75jXHT07WrOngL1WDXOp+yYS91Yg=="
},
"bn.js": {
"version": "4.11.8",
......@@ -1539,6 +1558,11 @@
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
},
"buffer-more-ints": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/buffer-more-ints/-/buffer-more-ints-0.0.2.tgz",
"integrity": "sha1-JrOIXRD6E9t/wBquOquHAZngEkw="
},
"buffer-xor": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
......
import { Injectable } from '@nestjs/common';
import { Injectable, Logger } from '@nestjs/common';
import * as amqp from 'amqplib/callback_api';
import { Email } from './email';
......@@ -11,11 +11,11 @@ export class EmailService {
// Connect to rabbitmq
amqp.connect(rabbitmqUrl, (err, conn) => {
if (err != null) { console.log(err); };
if (err != null) { Logger.log(err); }
// Create a communication channel
conn.createChannel((error, ch) => {
if (error != null) console.log(error);
if (error != null) Logger.log(error);
// Stringify and bufferise message
const buffer = Buffer.from(JSON.stringify(email));
......@@ -23,7 +23,7 @@ export class EmailService {
ch.sendToQueue(mailerQueue, buffer);
console.log(`sent to queue ${mailerQueue}: ${JSON.stringify(email)}`);
Logger.log(`sent to queue ${mailerQueue}: ${JSON.stringify(email)}`);
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment