11import express from "express" ;
22const app = express ( )
33
4- import { ExceptionlessClient } from "@exceptionless/node" ;
5- const client = ExceptionlessClient . default ;
6- client . config . apiKey = "LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw" ;
7- client . config . serverUrl = "http://localhost:5000" ;
8- client . config . useDebugLogger ( ) ;
9- client . config . useLocalStorage ( ) ;
4+ import { Exceptionless } from "@exceptionless/node" ;
5+
6+ Exceptionless . startup ( {
7+ apiKey : "LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw" ,
8+ serverUrl : "http://localhost:5000"
9+ } ) ;
10+
11+ Exceptionless . config . useDebugLogger ( ) ;
12+ Exceptionless . config . useLocalStorage ( ) ;
1013
1114// set some default data
12- client . config . defaultData [ "SampleUser" ] = {
15+ Exceptionless . config . defaultData [ "SampleUser" ] = {
1316 id :1 ,
1417 name : "Blake" ,
1518 password : "123456" ,
@@ -22,15 +25,15 @@ client.config.defaultData["SampleUser"] = {
2225 }
2326} ;
2427
25- client . config . defaultTags . push ( "Example" , "Node" ) ;
28+ Exceptionless . config . defaultTags . push ( "Example" , "Node" ) ;
2629
2730app . get ( "/" , function index ( req , res ) {
28- client . submitLog ( "loading index content" ) ;
31+ Exceptionless . submitLog ( "loading index content" ) ;
2932 res . send ( "Hello World!" ) ;
3033} ) ;
3134
3235app . get ( "/about" , function about ( req , res ) {
33- client . submitFeatureUsage ( "about" ) ;
36+ Exceptionless . submitFeatureUsage ( "about" ) ;
3437 res . send ( "About" ) ;
3538} ) ;
3639
@@ -39,12 +42,12 @@ app.get("/boom", function boom(req, res) {
3942} ) ;
4043
4144app . use ( function ( err , req , res , next ) {
42- client . createUnhandledException ( err , "express" ) . addRequestInfo ( req ) . submit ( ) ;
45+ Exceptionless . createUnhandledException ( err , "express" ) . addRequestInfo ( req ) . submit ( ) ;
4346 res . status ( 500 ) . send ( "Something broke!" ) ;
4447} ) ;
4548
4649app . use ( function ( req , res , next ) {
47- client . createNotFound ( req . originalUrl ) . addRequestInfo ( req ) . submit ( ) ;
50+ Exceptionless . createNotFound ( req . originalUrl ) . addRequestInfo ( req ) . submit ( ) ;
4851 res . status ( 404 ) . send ( "Sorry cant find that!" ) ;
4952} ) ;
5053
@@ -54,7 +57,7 @@ const server = app.listen(3000, function () {
5457
5558 var message = "Example app listening at http://" + host + port ;
5659 console . log ( message ) ;
57- client . submitLog ( "app" , message , "Info" ) ;
60+ Exceptionless . submitLog ( "app" , message , "Info" ) ;
5861} ) ;
5962
6063export default app ;
0 commit comments