Skip to content

Commit

Permalink
fix(common): remove HttpsServer decorator
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove `HttpsServer`. Use `Https.Server` as injectable type instead
  • Loading branch information
Romakita committed Apr 14, 2022
1 parent 5129d83 commit 292d01d
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 60 deletions.
2 changes: 1 addition & 1 deletion .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
],
"check-coverage": true,
"lines": 99.7,
"statements": 99.66,
"statements": 99.65,
"functions": 98.78,
"branches": 87.41
}
13 changes: 0 additions & 13 deletions packages/platform/common/src/decorators/httpsServer.spec.ts

This file was deleted.

32 changes: 0 additions & 32 deletions packages/platform/common/src/decorators/httpsServer.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/platform/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export * from "./config/interfaces/PlatformMulterSettings";
export * from "./config/interfaces/PlatformStaticsSettings";
export * from "./config/services/PlatformConfiguration";
export * from "./constants/routerOptions";
export * from "./decorators/httpServer";
export * from "./decorators/httpsServer";
export * from "./decorators/multer/multerFileSize";
export * from "./decorators/multer/multerOptions";
export * from "./decorators/multer/multipartFile";
Expand Down
5 changes: 0 additions & 5 deletions packages/platform/common/src/utils/createHttpsServer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {InjectorService} from "@tsed/di";
import {HttpsServer} from "../decorators/httpsServer";
import {createHttpsServer} from "./createHttpsServer";
import {expect} from "chai";
import Sinon from "sinon";
Expand All @@ -17,7 +16,6 @@ describe("createHttpsServer", () => {
const listener = createHttpsServer(injector, fn)!;

expect(!!injector.get(Https.Server)).to.be.eq(true);
expect(!!injector.get(HttpsServer)).to.be.eq(true);
expect(listener).to.be.a("function");

const server = injector.get(Https.Server);
Expand Down Expand Up @@ -47,7 +45,6 @@ describe("createHttpsServer", () => {
const listener = createHttpsServer(injector, fn);

expect(injector.get(Https.Server)).to.be.eq(null);
expect(injector.get(HttpsServer)).to.be.eq(null);

expect(listener).to.eq(undefined);
});
Expand All @@ -61,7 +58,6 @@ describe("createHttpsServer", () => {
const listener = createHttpsServer(injector, fn);

expect(!!injector.get(Https.Server)).to.be.eq(true);
expect(!!injector.get(HttpsServer)).to.be.eq(true);

expect(listener).to.be.a("function");
});
Expand All @@ -74,7 +70,6 @@ describe("createHttpsServer", () => {
const listener = createHttpsServer(injector, fn);

expect(!!injector.get(Https.Server)).to.be.eq(true);
expect(!!injector.get(HttpsServer)).to.be.eq(true);

expect(listener).to.be.a("function");
});
Expand Down
7 changes: 0 additions & 7 deletions packages/platform/common/src/utils/createHttpsServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {InjectorService, ProviderScope} from "@tsed/di";
import {getHostInfoFromPort} from "@tsed/core";
import Https from "https";
import Http from "http";
import {HttpsServer} from "../decorators/httpsServer";
import {listenServer} from "./listenServer";

export function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener) {
Expand All @@ -12,17 +11,11 @@ export function createHttpsServer(injector: InjectorService, requestListener?: H

const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;

injector.addProvider(HttpsServer, {
scope: ProviderScope.SINGLETON,
useValue: server
});

injector.addProvider(Https.Server, {
scope: ProviderScope.SINGLETON,
useValue: server
});

injector.invoke(HttpsServer);
injector.invoke(Https.Server);

if (server) {
Expand Down

0 comments on commit 292d01d

Please sign in to comment.