Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Fix tunneling example for Express #214

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tunneling/expressjs/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
const express = require("express");

// Allow body up to 100 MB
// Allow body up to 100 MB, regardless of Content-Type header
const app = express();

const envelopeParser = express.raw({limit: "100mb", type: () => true});

//TODO: Change this to suit your needs
const SENTRY_HOST = "oXXXXXX.ingest.sentry.io";
const SENTRY_KNOWN_PROJECTS = ["123456"]

//TODO: Put your routes here, make sure to keep the /bugs route at the end of your file
app.post("/bugs", async (req, res) => {
app.post("/bugs", envelopeParser, async (req, res) => {
try {
const envelope = req.body;

const piece = envelope.toString().split("\n")[0];
const piece = envelope.slice(0, envelope.indexOf("\n"));
const header = JSON.parse(piece);

const dsn = new URL(header.dsn);
Expand Down
6 changes: 3 additions & 3 deletions tunneling/expressjs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fastify-sentry-tunneling",
"name": "express-sentry-tunneling",
"version": "1.0.0",
"description": "Example to tunnel sentry using fastify",
"description": "Example to tunnel sentry using expressjs",
"author": "",
"main": "index.js",
"dependencies": {
Expand All @@ -11,4 +11,4 @@
"scripts": {
"start": "node ."
}
}
}