-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #4
- Loading branch information
Showing
10 changed files
with
5,047 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
examples/stack-traces-to-server/private-maps/bundle.private.min.js.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Example: Sending stack traces to your server</title> | ||
</head> | ||
<body> | ||
<h1>Sending stack traces to your server</h1> | ||
<p>All tests load code bundled from this file <code>/retrace/test/fixture/main.js</code></p> | ||
<h2>Private source maps</h2> | ||
<p>(configure retrace where exactly to get the source maps from)</p> | ||
<ul> | ||
<li><a href="bundle.private.min.html">Minified bundle with no public source map</a></li> | ||
</ul> | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
examples/stack-traces-to-server/private-maps/public/bundle.private.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>bundle.private.min.js</title> | ||
<script src="bundle.private.min.js"></script> | ||
</head> | ||
<body> | ||
... | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
examples/stack-traces-to-server/private-maps/public/bundle.private.min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var express = require('express'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var retrace = require('../../../'); | ||
|
||
retrace.resolve = function (url){ | ||
if(url && url.includes('bundle.private.min.js')){ | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(path.resolve(__dirname, 'bundle.private.min.js.map'), (err, data) => { | ||
if(err) | ||
reject(err); | ||
else | ||
resolve(JSON.parse(data)); | ||
}); | ||
}); | ||
} | ||
return null; | ||
}; | ||
|
||
console.log('resolving with private maps location'); | ||
|
||
var app = require('../server-common'); | ||
app.use(express.static(path.resolve(__dirname, 'public'))); | ||
app.get('/', function(req, res) { | ||
res.writeHead(200, { | ||
'Content-Type': 'text/html' | ||
}); | ||
fs.createReadStream(path.resolve(__dirname, 'index.html')).pipe(res); | ||
}); |
1 change: 1 addition & 0 deletions
1
examples/stack-traces-to-server/public-maps/bundle.private.min.js.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Example: Sending stack traces to your server</title> | ||
</head> | ||
<body> | ||
<h1>Sending stack traces to your server</h1> | ||
<p>All tests load code bundled from this file <code>/retrace/test/fixture/main.js</code></p> | ||
<p>Pick one of the test HTML files below and see how the code there will throw an error, catch it, send to the server for remapping and will print the remapped trace.</p> | ||
<h2>Having retrace to fetch the source maps itself</h2> | ||
<p>(by default retrace downloads the sources and source maps via HTTP)</p> | ||
<ul> | ||
<li><a href="bundle.html">Bundle</a></li> | ||
<li><a href="bundle.inline.html">Bundle with inline source map</a></li> | ||
<li><a href="bundle.min.html">Minified bundle</a></li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
console.log('resolving with public maps'); | ||
|
||
require('../server-common').get('/', function(req, res) { | ||
res.writeHead(200, { | ||
'Content-Type': 'text/html' | ||
}); | ||
fs.createReadStream(path.resolve(__dirname, 'index.html')).pipe(res); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
var express = require('express'); | ||
var http = require('http'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var retrace = require('../../'); | ||
|
||
/* Small express app that send sthe mapped stack trace back to the client. */ | ||
|
||
var app = express(); | ||
app.use(express.static(path.resolve(__dirname, '../../test/fixture'))); | ||
app.get('/retrace', function(req, res) { | ||
// Read the stack from a query parameter | ||
var stack = req.query.stack; | ||
// ... pass it to retrace | ||
retrace.map(stack).then(function(s) { | ||
// ... and send back the re-mapped stack trace | ||
res.send(s); | ||
}) | ||
.catch(function(err) { | ||
res.status(500).send(err); | ||
}) | ||
.finally(function() { | ||
res.end(); | ||
}) | ||
}); | ||
|
||
var server = http.createServer(app); | ||
server.listen(8001); | ||
|
||
console.log('server running. please check http://localhost:8001'); | ||
|
||
module.exports = app; |
Oops, something went wrong.