forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
55 lines (45 loc) · 1.42 KB
/
app.js
File metadata and controls
55 lines (45 loc) · 1.42 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
49
50
51
52
53
54
55
var express = require('express');
var app = express();
var client = require('../../dist/exceptionless.node').ExceptionlessClient.default;
client.config.apiKey = 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw';
client.config.serverUrl = 'http://localhost:50000';
client.config.useDebugLogger();
// set some default data
client.config.defaultData['SampleUser'] = {
id:1,
name: 'Blake',
password: '123456',
passwordResetToken: 'a reset token',
myPasswordValue: '123456',
myPassword: '123456',
customValue: 'Password',
value: {
Password: '123456'
}
};
client.config.defaultTags.push('Example', 'Node');
app.get('/', function (req, res) {
res.send('Hello World!');
});
app.get('/about', function (req, res) {
client.submitFeatureUsage('about');
res.send('About');
});
app.get('/boom', function (req, res) {
throw new Error('Boom!!');
});
app.use(function(err, req, res, next) {
client.createUnhandledException(err, 'express').addRequestInfo(req).submit();
res.status(500).send('Something broke!');
});
app.use(function(req, res, next) {
client.createNotFound(req.originalUrl).addRequestInfo(req).submit();
res.status(404).send('Sorry cant find that!');
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
var message = 'Example app listening at http://' + host + port;
console.log(message);
client.submitLog('app', message , 'Info');
});