Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vite-ssr-plugin): add
@Vite
decorator
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
packages/third-parties/vite-ssr-plugin/src/decorators/vite.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {Controller} from "@tsed/common"; | ||
import {Store} from "@tsed/core"; | ||
|
||
import {Vite} from "./vite"; | ||
|
||
@Controller("/") | ||
class ControllerTest { | ||
@Vite() | ||
post() { | ||
return; | ||
} | ||
|
||
@Vite("nice-view") | ||
postWithView() { | ||
return; | ||
} | ||
} | ||
|
||
describe("ViteDecorator", () => { | ||
it("should return attached View with *.vite with empty path", async () => { | ||
const metadata = Store.fromMethod(ControllerTest, "post").get("view"); | ||
|
||
expect(metadata.path).toEqual("*.vite"); | ||
}); | ||
|
||
it("should return attached View with {path}.vite", async () => { | ||
const metadata = Store.fromMethod(ControllerTest, "postWithView").get("view"); | ||
|
||
expect(metadata.path).toEqual("nice-view.vite"); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
packages/third-parties/vite-ssr-plugin/src/decorators/vite.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {View} from "@tsed/schema"; | ||
|
||
export function Vite(path?: string) { | ||
return View(`${path || "*"}.vite`); | ||
} |
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