feat(navigation): add bindProductionNavigation(config) DI helper
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts",
|
".": "./src/index.ts",
|
||||||
"./cms": "./src/integrations/cms/index.ts",
|
"./cms": "./src/integrations/cms/index.ts",
|
||||||
"./api": "./src/integrations/api/router.ts"
|
"./api": "./src/integrations/api/router.ts",
|
||||||
|
"./di/bind-production": "./src/di/bind-production.ts"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --noEmit",
|
"build": "tsc --noEmit",
|
||||||
|
|||||||
13
packages/navigation/src/di/bind-production.ts
Normal file
13
packages/navigation/src/di/bind-production.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import type { SanitizedConfig } from "payload";
|
||||||
|
import { navigationContainer } from "./container";
|
||||||
|
import { NAVIGATION_SYMBOLS } from "./symbols";
|
||||||
|
import { PayloadHeaderRepository } from "../infrastructure/repositories/payload-header.repository";
|
||||||
|
|
||||||
|
export function bindProductionNavigation(config: SanitizedConfig): void {
|
||||||
|
if (navigationContainer.isBound(NAVIGATION_SYMBOLS.IHeaderRepository)) {
|
||||||
|
navigationContainer.unbind(NAVIGATION_SYMBOLS.IHeaderRepository);
|
||||||
|
}
|
||||||
|
navigationContainer
|
||||||
|
.bind(NAVIGATION_SYMBOLS.IHeaderRepository)
|
||||||
|
.toConstantValue(new PayloadHeaderRepository(config));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user