Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将nestjs与sentry集成_Javascript_Nestjs - Fatal编程技术网

Javascript 将nestjs与sentry集成

Javascript 将nestjs与sentry集成,javascript,nestjs,Javascript,Nestjs,我想将sentry与nest.js+express集成,但我刚找到raven版本,但不推荐使用。 我遵循sentry文档与express集成,但不知道如何处理“所有控制器都应该住在这里”部分 const express = require('express'); const app = express(); const Sentry = require('@sentry/node'); Sentry.init({ dsn: 'https://5265e36cb9104baf9b3109bb5d

我想将sentry与nest.js+express集成,但我刚找到raven版本,但不推荐使用。 我遵循sentry文档与express集成,但不知道如何处理“所有控制器都应该住在这里”部分

const express = require('express');
const app = express();
const Sentry = require('@sentry/node');

Sentry.init({ dsn: 'https://5265e36cb9104baf9b3109bb5da9423e@sentry.io/1768434' });

// The request handler must be the first middleware on the app
app.use(Sentry.Handlers.requestHandler());

**// All controllers should live here
app.get('/', function rootHandler(req, res) {
  res.end('Hello world!');
});**

// The error handler must be before any other error middleware and after all controllers
app.use(Sentry.Handlers.errorHandler());

// Optional fallthrough error handler
app.use(function onError(err, req, res, next) {
  // The error id is attached to `res.sentry` to be returned
  // and optionally displayed to the user for support.
  res.statusCode = 500;
  res.end(res.sentry + "\n");
});

app.listen(3000);

要将sentry与nestjs集成,我们需要遵循以下步骤:

  • 安装npm i nest raven
  • 主要是
  • 用于app.module.ts中的所有控制器

  • 问题一直在这里跟踪,你可以举个例子。

    你的问题不清楚,但是对于你提供的代码,除了没有与nest.js集成之外,它还有什么问题吗?一切都很好,只是这部分代码是问题app.get('/',function rootHandler(req,res){res.end('Hello world!';});
    async function bootstrap() {
      Sentry.init({ dsn: 'https://5265e36cb9104baf9b3109bb5da9423e@sentry.io/1768434' });
      const app = await NestFactory.create(AppModule);
      // middlewares
      await app.listen(3000);
    }
    
    @Module({
      imports: [
        RavenModule,...
      ],
      controllers: [],
      providers: [{
        provide: APP_INTERCEPTOR,
        useValue: new RavenInterceptor({
          filters: [
            // Filter exceptions of type HttpException. Ignore those that
            // have status code of less than 500
            { type: HttpException, filter: (exception: HttpException) => 500 > exception.getStatus() },
          ],
        }),
      }],
    })