-
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(common): Move Render decorator inside PlatformExpress. Refactorin…
…g Platform Express
- Loading branch information
Romain Lenzotti
committed
Jun 14, 2020
1 parent
367c0b7
commit 4644f15
Showing
42 changed files
with
481 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export * from "./interfaces/IServerSettings"; | ||
export * from "./interfaces/IServerMountDirectories"; | ||
export * from "./interfaces/ILoggerSettings"; | ||
export * from "./interfaces/IRouterSettings"; | ||
export * from "./interfaces/IErrorSettings"; | ||
export * from "./services/ServerSettingsService"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 8 additions & 18 deletions
26
packages/common/src/mvc/decorators/method/acceptMime.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,16 @@ | ||
import {AcceptMime, AcceptMimesMiddleware} from "@tsed/common"; | ||
import {Store} from "@tsed/core"; | ||
import {expect} from "chai"; | ||
import * as Proxyquire from "proxyquire"; | ||
import * as Sinon from "sinon"; | ||
import {AcceptMimesMiddleware} from "../../../../src/mvc"; | ||
|
||
const middleware: any = Sinon.stub(); | ||
const useBeforeStub: any = Sinon.stub().returns(middleware); | ||
|
||
const {AcceptMime} = Proxyquire.load("../../../../src/mvc/decorators/method/acceptMime", { | ||
"./useBefore": {UseBefore: useBeforeStub} | ||
}); | ||
|
||
class Test {} | ||
|
||
describe("AcceptMime", () => { | ||
it("should set metadata", () => { | ||
const descriptor = {}; | ||
const options = "application/json"; | ||
AcceptMime("application/json")(Test, "test", descriptor); | ||
const store = Store.from(Test, "test", descriptor); | ||
expect(store.get(AcceptMimesMiddleware)).to.deep.eq([options]); | ||
useBeforeStub.should.be.calledWith(AcceptMimesMiddleware); | ||
middleware.should.be.calledWith(Test, "test", descriptor); | ||
class Test { | ||
@AcceptMime("application/json") | ||
test() {} | ||
} | ||
|
||
const store = Store.fromMethod(Test, "test"); | ||
expect(store.get(AcceptMimesMiddleware)).to.deep.eq(["application/json"]); | ||
}); | ||
}); |
40 changes: 11 additions & 29 deletions
40
packages/common/src/mvc/decorators/method/contentType.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,22 @@ | ||
import {assert, expect} from "chai"; | ||
import * as Proxyquire from "proxyquire"; | ||
import {ContentType, EndpointRegistry} from "@tsed/common"; | ||
import {Store} from "@tsed/core"; | ||
import {expect} from "chai"; | ||
import * as Sinon from "sinon"; | ||
import {FakeResponse} from "../../../../../../test/helper"; | ||
|
||
const middleware: any = Sinon.stub(); | ||
const useAfterStub: any = Sinon.stub().returns(middleware); | ||
|
||
const {ContentType} = Proxyquire.load("../../../../src/mvc/decorators/method/contentType", { | ||
"./useAfter": {UseAfter: useAfterStub} | ||
}); | ||
|
||
class Test {} | ||
|
||
describe("ContentType", () => { | ||
const descriptor = {}; | ||
const options = "application/json"; | ||
|
||
it("should create middleware", () => { | ||
ContentType(options)(Test, "test", descriptor); | ||
|
||
expect(useAfterStub.args[0][0]).to.be.a("function"); | ||
assert(middleware.calledWith(Test, "test", descriptor)); | ||
}); | ||
|
||
it("should call response method", () => { | ||
const nextSpy = Sinon.stub(); | ||
const response = new FakeResponse(); | ||
Sinon.stub(response, "type"); | ||
|
||
ContentType(options)(Test, "test", descriptor); | ||
|
||
const middleware = useAfterStub.args[0][0]; | ||
middleware({}, response, nextSpy); | ||
|
||
// @ts-ignore | ||
assert(response.type.calledWith(options), "method not called"); | ||
assert(nextSpy.called, "function not called"); | ||
class Test { | ||
@ContentType("application/json") | ||
test() {} | ||
} | ||
|
||
const store = Store.fromMethod(Test, "test"); | ||
expect(store.get("produces")).to.deep.eq(["application/json"]); | ||
EndpointRegistry.get(Test, "test").afterMiddlewares.length.should.eq(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
packages/common/src/mvc/decorators/method/responseView.spec.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.