-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
connect.js
35 lines (27 loc) · 898 Bytes
/
connect.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// errormailer works only in production mode
process.env.NODE_ENV = 'production';
var nodemailer = require('nodemailer');
var errormailer = require("../");
var connect = require("connect");
// Create a SMTP transport object
var transport = nodemailer.createTransport("SMTP", {
service: 'Sendgrid', // use well known service
auth: {
user: process.env.USERNAME,
pass: process.env.PASSWORD
}
});
console.log('SMTP Configured');
var errorHandler = errormailer(transport, {
subject: "Testing errormailer!",
to: "matteo.collina@gmail.com"
});
var funcErr = function(req, res) { throw new Error("AHAHH"); };
var app = connect().
use(funcErr).
use(errorHandler).
use(connect.errorHandler({dumpException: true, showStack: true})).
listen(process.env.PORT || 3000,
function() {
console.log("ErrorMailer connect demo started at port 3000");
});