feat(blog): add bindProductionBlog(config) DI helper for app boot
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/blog/src/di/bind-production.ts
Normal file
13
packages/blog/src/di/bind-production.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import type { SanitizedConfig } from "payload";
|
||||||
|
import { blogContainer } from "./container";
|
||||||
|
import { BLOG_SYMBOLS } from "./symbols";
|
||||||
|
import { PayloadArticlesRepository } from "../infrastructure/repositories/payload-articles.repository";
|
||||||
|
|
||||||
|
export function bindProductionBlog(config: SanitizedConfig): void {
|
||||||
|
if (blogContainer.isBound(BLOG_SYMBOLS.IArticlesRepository)) {
|
||||||
|
blogContainer.unbind(BLOG_SYMBOLS.IArticlesRepository);
|
||||||
|
}
|
||||||
|
blogContainer
|
||||||
|
.bind(BLOG_SYMBOLS.IArticlesRepository)
|
||||||
|
.toConstantValue(new PayloadArticlesRepository(config));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user