Skip to content

Commit

Permalink
fix(platform-router): exclude ws verbs
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Oct 26, 2023
1 parent a3a39c4 commit 0d6dc1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {getValue, Hooks, Type} from "@tsed/core";
import {ControllerProvider, GlobalProviders, Injectable, InjectorService, Provider, ProviderType, TokenProvider} from "@tsed/di";
import {concatPath, getOperationsRoutes} from "@tsed/schema";
import {concatPath, getOperationsRoutes, OPERATION_HTTP_VERBS} from "@tsed/schema";
import {useContextHandler} from "../utils/useContextHandler";
import {PlatformLayer} from "./PlatformLayer";
import {PlatformRouter} from "./PlatformRouter";
Expand Down Expand Up @@ -42,6 +42,7 @@ GlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {
@Injectable()
export class PlatformRouters {
readonly hooks = new Hooks();
readonly allowedVerbs = OPERATION_HTTP_VERBS;

constructor(protected readonly injector: InjectorService) {}

Expand Down Expand Up @@ -69,7 +70,7 @@ export class PlatformRouters {

const {children} = provider;

getOperationsRoutes(provider.token).forEach((operationRoute) => {
getOperationsRoutes(provider.token, {allowedVerbs: this.allowedVerbs}).forEach((operationRoute) => {
const {endpoint} = operationRoute;
const {beforeMiddlewares, middlewares: mldwrs, afterMiddlewares} = endpoint;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {catchError} from "@tsed/core";
import {Controller, InjectorService} from "@tsed/di";
import {UseBefore} from "@tsed/platform-middlewares";
import {Context, PlatformParams} from "@tsed/platform-params";
import {Delete, Get, Head, Options, Patch, Post, Put} from "@tsed/schema";
import {Delete, Get, Head, Options, Patch, Post, Publish, Put, Subscribe} from "@tsed/schema";
import {PlatformRouter} from "../src/domain/PlatformRouter";
import {PlatformRouters} from "../src/domain/PlatformRouters";

Expand Down Expand Up @@ -35,11 +35,13 @@ class NestedController {
@UseBefore(function useBefore() {})
class MyController {
@Get("/")
@Publish("get.event")
get(@Context() $ctx: Context) {
return $ctx;
}

@Post("/")
@Subscribe("update.event")
post() {}

@Put("/:id")
Expand Down

0 comments on commit 0d6dc1e

Please sign in to comment.