-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtools.js
More file actions
48 lines (34 loc) · 1.19 KB
/
tools.js
File metadata and controls
48 lines (34 loc) · 1.19 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
tools.js
A miscellaneous module that adds additional functionality to your web application
DO NOT NEED TO MODIFY!!!
*/
module.exports = {
/* logger
This function adds a simple logger to your application.
Now on the console for every request that comes in your browser, this logger will notify you of the request,
what method was asked for, and what was the response code that the server sent.
*/
logger: function(req, res, next) {
function afterResponse() {
res.removeListener('finish', afterResponse);
res.removeListener('close', afterResponse);
console.log(req.method + " request received for path " + req.originalUrl + " with status " + res.statusCode);
}
res.on('finish', afterResponse);
res.on('close', afterResponse);
next();
},
/* getMailAuthObject
Returns an object with the authentication parameters needed to authenticate to the external Mailgun API. Grabs
username and password values from the system environment for security purposes.
*/
getMailAuthObject: function() {
user = process.env.MAILGUN_USERNAME;
password = process.env.MAILGUN_PASSWORD;
return {
'user': username,
'password': password
};
}
};