@mastra/nestjs 0.1.6-alpha.0 → 0.1.6-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12602,7 +12602,10 @@ function getMastraRoutePath(path, prefix) {
12602
12602
  normalizedPrefix = normalizedPrefix.slice(0, -1);
12603
12603
  }
12604
12604
  let routePath = path;
12605
- if (normalizedPrefix && (path === normalizedPrefix || path.startsWith(normalizedPrefix + "/"))) {
12605
+ if (normalizedPrefix) {
12606
+ if (path !== normalizedPrefix && !path.startsWith(normalizedPrefix + "/")) {
12607
+ return null;
12608
+ }
12606
12609
  routePath = path.slice(normalizedPrefix.length);
12607
12610
  if (routePath && !routePath.startsWith("/")) {
12608
12611
  routePath = "/" + routePath;
@@ -12826,6 +12829,9 @@ var MastraRouteGuard = class {
12826
12829
  const request = context.switchToHttp().getRequest();
12827
12830
  const method = request.method.toUpperCase();
12828
12831
  const routePath = getMastraRoutePath(request.path, this.options.prefix);
12832
+ if (!routePath) {
12833
+ return true;
12834
+ }
12829
12835
  const matchResult = this.routeHandler.matchRoute(method, routePath);
12830
12836
  if (!matchResult) {
12831
12837
  return true;
@@ -13413,7 +13419,7 @@ var TracingInterceptor = class _TracingInterceptor {
13413
13419
  const request = context.switchToHttp().getRequest();
13414
13420
  const response = context.switchToHttp().getResponse();
13415
13421
  const routePath = getMastraRoutePath(request.path, this.options.prefix);
13416
- const matchResult = this.routeHandler.matchRoute(request.method.toUpperCase(), routePath);
13422
+ const matchResult = routePath ? this.routeHandler.matchRoute(request.method.toUpperCase(), routePath) : null;
13417
13423
  const routeTemplate = matchResult?.route.path ?? request.route?.path ?? request.path;
13418
13424
  const span = tracer.startSpan(`HTTP ${request.method} ${routeTemplate}`, {
13419
13425
  kind: otel.SpanKind.SERVER,
@@ -13557,6 +13563,9 @@ var MastraController = class {
13557
13563
  const path = req.path;
13558
13564
  const method = req.method.toUpperCase();
13559
13565
  const routePath = getMastraRoutePath(path, this.options.prefix);
13566
+ if (!routePath) {
13567
+ throw new NotFoundException(`Route not found: ${method} ${path}`);
13568
+ }
13560
13569
  if (routePath.includes("//")) {
13561
13570
  throw new NotFoundException(`Route not found: ${method} ${path}`);
13562
13571
  }