-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
64 additions
and
49 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
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,16 @@ | ||
import { FrontendService } from "../services/frontend/frontendService"; | ||
import { http } from "@deepkit/http"; | ||
|
||
@http.controller("/") | ||
export class FrontendController { | ||
constructor(protected frontendService: FrontendService) {} | ||
|
||
@(http.GET("").description("Home page")) | ||
async home() { | ||
return this.frontendService.renderAppTemplate({}); | ||
} | ||
|
||
// Route for hot module replacement event stream, handled by the webpackHotMiddleware below. | ||
@http.GET("/__webpack_hmr") | ||
async hmr() {} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { AppModule } from "@deepkit/app"; | ||
import { FrontendService } from "../services/frontend/frontendService"; | ||
import { httpMiddleware } from "@deepkit/http"; | ||
import { serveStaticListener } from "@deepkit/http"; | ||
import { EntitiesService } from "../services/entities/entitiesService"; | ||
import path from "path"; | ||
import { CrudService } from "../services/crud/crudService"; | ||
import webpackDevMiddleware from "webpack-dev-middleware"; | ||
import webpackHotMiddleware from "webpack-hot-middleware"; | ||
import webpack from "webpack"; | ||
import { FrontendController } from "../controllers/FrontendController"; | ||
import { CrudController } from "../controllers/CrudController"; | ||
|
||
const webpackConfig = require("../client/webpack.config.js"); | ||
const { publicPath } = webpackConfig.output; | ||
const compiler = webpack(webpackConfig); | ||
|
||
const publicDir = path.resolve(__dirname, "..", "..", "public"); | ||
const servePublic = serveStaticListener("/public", publicDir); | ||
export const FrontendModule = new AppModule( | ||
{ | ||
controllers: [FrontendController, CrudController], | ||
providers: [{ provide: FrontendService, scope: "http" }, EntitiesService, CrudService], | ||
listeners: [servePublic], | ||
middlewares: [ | ||
httpMiddleware.for(webpackDevMiddleware(compiler, { publicPath: publicPath.Path, writeToDisk: true })), | ||
httpMiddleware.for(webpackHotMiddleware(compiler)), | ||
], | ||
}, | ||
"frontend" | ||
); |
File renamed without changes.