1- require ( './tracing' ) ;
1+ import type * as S from '@sentry/node' ;
2+ const Sentry = require ( '@sentry/node' ) as typeof S ;
3+
4+ Sentry . init ( {
5+ environment : 'qa' , // dynamic sampling bias to keep transactions
6+ dsn : process . env . E2E_TEST_DSN ,
7+ integrations : [ ] ,
8+ tracesSampleRate : 1 ,
9+ tunnel : 'http://localhost:3031/' , // proxy server
10+ tracePropagationTargets : [ 'http://localhost:3030' , '/external-allowed' ] ,
11+ } ) ;
12+
13+ import type * as H from 'http' ;
14+ import type * as F from 'fastify' ;
215
3- const Sentry = require ( '@sentry/node' ) ;
4- const { fastify } = require ( 'fastify' ) ;
5- const http = require ( 'http' ) ;
16+ // Make sure fastify is imported after Sentry is initialized
17+ const { fastify } = require ( 'fastify' ) as typeof F ;
18+ const http = require ( 'http' ) as typeof H ;
619
720const app = fastify ( ) ;
821const port = 3030 ;
922const port2 = 3040 ;
1023
1124Sentry . setupFastifyErrorHandler ( app ) ;
1225
13- app . get ( '/test-success' , function ( req , res ) {
26+ app . get ( '/test-success' , function ( _req , res ) {
1427 res . send ( { version : 'v1' } ) ;
1528} ) ;
1629
17- app . get ( '/test-param/:param' , function ( req , res ) {
30+ app . get < { Params : { param : string } } > ( '/test-param/:param' , function ( req , res ) {
1831 res . send ( { paramWas : req . params . param } ) ;
1932} ) ;
2033
21- app . get ( '/test-inbound-headers/:id' , function ( req , res ) {
34+ app . get < { Params : { id : string } } > ( '/test-inbound-headers/:id' , function ( req , res ) {
2235 const headers = req . headers ;
2336
2437 res . send ( { headers, id : req . params . id } ) ;
2538} ) ;
2639
27- app . get ( '/test-outgoing-http/:id' , async function ( req , res ) {
40+ app . get < { Params : { id : string } } > ( '/test-outgoing-http/:id' , async function ( req , res ) {
2841 const id = req . params . id ;
2942 const data = await makeHttpRequest ( `http://localhost:3030/test-inbound-headers/${ id } ` ) ;
3043
3144 res . send ( data ) ;
3245} ) ;
3346
34- app . get ( '/test-outgoing-fetch/:id' , async function ( req , res ) {
47+ app . get < { Params : { id : string } } > ( '/test-outgoing-fetch/:id' , async function ( req , res ) {
3548 const id = req . params . id ;
3649 const response = await fetch ( `http://localhost:3030/test-inbound-headers/${ id } ` ) ;
3750 const data = await response . json ( ) ;
@@ -55,7 +68,7 @@ app.get('/test-error', async function (req, res) {
5568 res . send ( { exceptionId } ) ;
5669} ) ;
5770
58- app . get ( '/test-exception/:id' , async function ( req , res ) {
71+ app . get < { Params : { id : string } } > ( '/test-exception/:id' , async function ( req , res ) {
5972 throw new Error ( `This is an exception with id ${ req . params . id } ` ) ;
6073} ) ;
6174
@@ -101,9 +114,9 @@ app2.get('/external-disallowed', function (req, res) {
101114
102115app2 . listen ( { port : port2 } ) ;
103116
104- function makeHttpRequest ( url ) {
117+ function makeHttpRequest ( url : string ) {
105118 return new Promise ( resolve => {
106- const data = [ ] ;
119+ const data : any [ ] = [ ] ;
107120
108121 http
109122 . request ( url , httpRes => {
0 commit comments