-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- tokens: добавлены токены для express-приложения, промежуточных слоев и маршрутов (minor) - preset/node: добавлены компоненты express-приложения, промежуточных слоев и маршрутов (minor) - docs: доработки по утилитам для redux (patch) - examples: учтены новые компоненты пресета (patch)
- Loading branch information
Showing
8 changed files
with
92 additions
and
38 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
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 express from 'express'; | ||
import type { Resolve } from '../../../di'; | ||
import { KnownToken } from '../../../tokens'; | ||
|
||
/** | ||
* Провайдер основного express-приложения. | ||
* @param resolve Функция для получения зависимости по токену. | ||
* @return Основное express-приложение. | ||
*/ | ||
export function provideMainExpressApp(resolve: Resolve): express.Application { | ||
const pageRoutes = resolve(KnownToken.Express.pageRoutes); | ||
const serviceRoutes = resolve(KnownToken.Express.serviceRoutes); | ||
const middleware = resolve(KnownToken.Express.middleware); | ||
const endMiddleware = resolve(KnownToken.Express.endMiddleware); | ||
|
||
const app = express(); | ||
|
||
// маршруты страниц | ||
for (const [routePath, routeHandler] of pageRoutes) { | ||
app.use(routePath, middleware); | ||
app.get(routePath, routeHandler); | ||
app.use(routePath, endMiddleware); | ||
} | ||
|
||
// служебные маршруты (к ним не применяются промежуточные слои) | ||
for (const [routePath, routeHandler] of serviceRoutes) { | ||
app.get(routePath, routeHandler); | ||
} | ||
|
||
return app; | ||
} |
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