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 Nov 16, 2023
1 parent 63a011b commit f92c0bf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 174 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
4 changes: 2 additions & 2 deletions packages/specs/schema/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ module.exports = {
roots: ["<rootDir>/src", "<rootDir>/test"],
coverageThreshold: {
global: {
statements: 99.45,
statements: 99.41,
branches: 96.19,
functions: 100,
lines: 99.45
lines: 99.41
}
},
moduleNameMapper: {
Expand Down
7 changes: 1 addition & 6 deletions packages/specs/schema/src/domain/JsonEntityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,7 @@ export abstract class JsonEntityStore implements JsonEntityStoreOptions {

if (!store.has("JsonEntityStore")) {
const decoratorType = decoratorTypeOf(args);
const entityStore = JsonEntitiesContainer.get(decoratorType);

// istanbul ignore next
if (!entityStore) {
throw Error("Unsupported json entity type");
}
const entityStore = JsonEntitiesContainer.get(decoratorType)!;

const jsonSchemaStore = new entityStore({
store,
Expand Down
163 changes: 0 additions & 163 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5614,70 +5614,6 @@
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e"
integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==

"@tsed/common@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/common/-/common-7.44.1.tgz#631b465eb867847baca80c5076134a98eafa1762"
integrity sha512-Eq342Vn1Cg7lp2Qr8/3tB9rIsvR6IHsFYxYqWh1YyL3NtY469o5in5jgcQqDU5JZss+cd3vnbCrlPA1FrVzx/w==
dependencies:
"@tsed/core" "7.44.1"
"@tsed/di" "7.44.1"
"@tsed/exceptions" "7.44.1"
"@tsed/json-mapper" "7.44.1"
"@tsed/logger" ">=6.2.2"
"@tsed/logger-file" ">=6.2.2"
"@tsed/platform-exceptions" "7.44.1"
"@tsed/platform-log-middleware" "7.44.1"
"@tsed/platform-middlewares" "7.44.1"
"@tsed/platform-params" "7.44.1"
"@tsed/platform-response-filter" "7.44.1"
"@tsed/platform-router" "7.44.1"
"@tsed/platform-views" "7.44.1"
"@tsed/schema" "7.44.1"
"@types/json-schema" "7.0.11"
accepts "^1.3.8"
tslib "2.5.0"
uuid "8.3.2"

"@tsed/core@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/core/-/core-7.44.1.tgz#75376f747d8e3ea59c4685a776e81167b694a14a"
integrity sha512-mhlOZlEmQHxk5Jk6anmATkJyLYkxMVdZtONuQys5volfYLbENSL3UQgIief4TH/d8eOXeh8F5vvEO9hp9pw6Vw==
dependencies:
reflect-metadata "^0.1.13"
tslib "2.5.0"

"@tsed/di@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/di/-/di-7.44.1.tgz#1473542678eb7ca265f2f31b9d9118458893317c"
integrity sha512-4+Dnwflc+m2wOrVGoREC1PAvLOMSUtUnHlA7vIz2y++iJfEPlB/STCgFT2bKht9hxA22AkU0tNK+HvxvEOS0dg==
dependencies:
tslib "2.5.0"

"@tsed/engines@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/engines/-/engines-7.44.1.tgz#614981e86466fec4cf1235ccf2586ba63a9cebd3"
integrity sha512-vhePGFHd13Q2JwYRYLuIyY69CVxJFVSRi0YxLlKyRsPRtUm134SPj9V5of52M/qSHw1PNKToc0aydCJdYUL4CQ==
dependencies:
filedirname "^2.7.0"
fs-extra "11.1.1"
tslib "2.5.0"

"@tsed/exceptions@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/exceptions/-/exceptions-7.44.1.tgz#bf4a2adfdc048639b37d002f1f9271c6c1d289ec"
integrity sha512-CSZqT1uE06zpdAwqaP+KSb2ZNPZMumIOE3IXCeMoZQZpn9G5D2x3QuYKRw1g+/JdiGFG+vsoZAcwA+X0KfbBAQ==
dependencies:
change-case "4.1.2"
statuses ">=2.0.1"
tslib "2.5.0"

"@tsed/json-mapper@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/json-mapper/-/json-mapper-7.44.1.tgz#3d1ed4a9492f73d9ed52211301a97f0b4278f8c8"
integrity sha512-Zi0Y4nt76e1aQf/4Cxd7ZRep1jajy/KODdySenosd9odQBtAumTcEa83NGN+jSn/ZDyyDK3QojYSfJZa73qFVw==
dependencies:
tslib "2.5.0"

"@tsed/logger-file@>=6.2.2":
version "6.2.2"
resolved "https://registry.yarnpkg.com/@tsed/logger-file/-/logger-file-6.2.2.tgz#ffd1f9ab1a0e09160433676976c370a0800ba674"
Expand Down Expand Up @@ -5717,105 +5653,6 @@
normalize-path "3.0.0"
semver "7.3.7"

"@tsed/normalize-path@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/normalize-path/-/normalize-path-7.44.1.tgz#aaa92261bf740f72e16ed81585bc1fd88775d151"
integrity sha512-TuxA3mjbB4KCpZjGIoNuZWqFbBJ7JYYHdxOnK55UaWExEcYJQ1thQwnAUBmLmbq2tQcpx5gd5LQ4iXTvyK5ogw==
dependencies:
normalize-path "3.0.0"
tslib "2.5.0"

"@tsed/openspec@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/openspec/-/openspec-7.44.1.tgz#7664ad073d87ffb0b489bc237d7a786af53f8c9d"
integrity sha512-u8swBkR6xDyMPnaIWTb2Oqtomciq73Lttm38RxcnMbqvXx9ZlOcF1k02bRJVhNcJROYJP5kAj23KeZak/eyM5Q==

"@tsed/platform-exceptions@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/platform-exceptions/-/platform-exceptions-7.44.1.tgz#7d18a2814f3b41c66f11a25089affb17a0d709d5"
integrity sha512-ORsFyr9TvBLFWktekRVf0QjcigreOKcwRUxmL5MXTTvtIBlmV4ZN/SqL7M8/bOLBF5Y32mqAeZlrymmBNe3V+g==
dependencies:
tslib "2.5.0"

"@tsed/platform-express@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/platform-express/-/platform-express-7.44.1.tgz#47e4e07a0e32a427fe31266ec2087376c51b3cd6"
integrity sha512-ZYQGIKo3HEeFqQHOXLIPrkEbhESvdwraDQUNEEdbZ9Fb3rwnzcg5FeRyU664L4ZdjZU/NPNyWdZ9qjtHnAmVQw==
dependencies:
express "^4.18.1"
multer "^1.4.5-lts.1"
tslib "2.5.0"

"@tsed/platform-log-middleware@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/platform-log-middleware/-/platform-log-middleware-7.44.1.tgz#393b569c1a896131df1464441949a6cbdc4e50b2"
integrity sha512-wFXFuClcfp4miKcXc5cRoMYG/VMngmsBxqDwQzYwdv3PwNFOn7stI1KcOAaMRMVOAOhaBUwPROXRuMWnG9uX+A==
dependencies:
tslib "2.5.0"

"@tsed/platform-middlewares@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/platform-middlewares/-/platform-middlewares-7.44.1.tgz#c2426e7e85acb64b06c366e5134f5fb649f47a9b"
integrity sha512-/bVYHWGVVAPDN7xGIuL/ZH86hzmgS1gm5CebdWOpk4MRd4SSp5LMdt2qFZxE7zXH6nPdySbaEEhxnjxpum0M9w==
dependencies:
tslib "2.5.0"

"@tsed/platform-params@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/platform-params/-/platform-params-7.44.1.tgz#776bf3f7c25d142173f40b418faf1db26353de47"
integrity sha512-iepzpfduh59Za2/QcmubzKaWbeoheekYIzaMVoWf6PO8k8O4PWyO6amUfurHnEn8KgJ/VZEzWtijrETGx2+NfQ==
dependencies:
tslib "2.5.0"

"@tsed/platform-response-filter@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/platform-response-filter/-/platform-response-filter-7.44.1.tgz#eef38a2251ba64454e442ba74226005bfa375261"
integrity sha512-1oJWKvaa6HmCIZDxKuGrRDCDXguTbqHyCF0Ci6gFX2Ih/P987AyuF7bZukHRwSQc3sgsi0K12PKANhvE5/fIdw==
dependencies:
tslib "2.5.0"

"@tsed/platform-router@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/platform-router/-/platform-router-7.44.1.tgz#8454b0e456236822a9f6513c19f702c57c670505"
integrity sha512-NwanjBvGXFAYlN1Y4RINMIkcbRFOlNWpoWhQTgoiyIKcrtXKsBiuwr/xmii6noEzbci0GLcoTKCGkTTasogZnQ==
dependencies:
tslib "2.5.0"

"@tsed/platform-views@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/platform-views/-/platform-views-7.44.1.tgz#7bedfb7558984362802daed6dc5df7f3a072c245"
integrity sha512-V7schhr/TI3L+OUNf6hTgNGadrusfe5YPp1MdEetSUfc7GPR/Sr00hVw2NrTNMJKbWAKYAp91XmU0QsmnZcuNw==
dependencies:
"@tsed/engines" "7.44.1"
ejs "^3.1.5"
tslib "2.5.0"

"@tsed/schema@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/schema/-/schema-7.44.1.tgz#a3861a5702a6e3909eb23d05543f5def15841a41"
integrity sha512-vX6TKk0fvqGL3hywqMK6VFUAHO6TLeXtA5kPEqmkoiN4P3Ol5gZkXARFrJgbqeJMsGq02/GW2d/GCinAfkdUcA==
dependencies:
"@tsed/openspec" "7.44.1"
change-case "^4.1.2"
fs-extra "^11.1.1"
json-schema "0.4.0"
picomatch "2.3.1"
statuses ">=2.0.1"
tslib "2.5.0"

"@tsed/swagger@7.44.1":
version "7.44.1"
resolved "https://registry.yarnpkg.com/@tsed/swagger/-/swagger-7.44.1.tgz#2684a5d8bd02a3e582c228407b1568a090cff2a3"
integrity sha512-Ats2iNWsp1LvcUzSmDw8vgqru4wHJjcz6+bZfkeW2ljPpNPEgOocvR76iSb6xEzAyqmHpCe3yzPJBa0igu+sWQ==
dependencies:
"@tsed/normalize-path" "7.44.1"
"@tsed/openspec" "7.44.1"
filedirname "^2.7.0"
fs-extra "11.1.1"
micromatch "4.0.5"
swagger-ui-dist "^4.5.2"
tslib "2.5.0"

"@tsed/ts-doc@4.0.14":
version "4.0.14"
resolved "https://registry.yarnpkg.com/@tsed/ts-doc/-/ts-doc-4.0.14.tgz#6f09a1b09962354c0a1e7847f475a3e35a191eed"
Expand Down

0 comments on commit f92c0bf

Please sign in to comment.