feat(marketing-pages): add Mock pages + site-settings repositories
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
import "reflect-metadata";
|
||||||
|
import { injectable } from "inversify";
|
||||||
|
|
||||||
|
import type { IPagesRepository } from "../../application/repositories/pages-repository.interface";
|
||||||
|
import type { Page } from "../../entities/page";
|
||||||
|
|
||||||
|
const SEED_DATE = new Date("2026-01-01T00:00:00.000Z");
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class MockPagesRepository implements IPagesRepository {
|
||||||
|
private _pages: Page[] = [
|
||||||
|
{
|
||||||
|
id: "p1",
|
||||||
|
title: "About",
|
||||||
|
slug: "about",
|
||||||
|
hero: { heading: "About us" },
|
||||||
|
layout: [],
|
||||||
|
status: "published",
|
||||||
|
publishedAt: SEED_DATE,
|
||||||
|
seo: { title: "About — My App" },
|
||||||
|
createdAt: SEED_DATE,
|
||||||
|
updatedAt: SEED_DATE,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
async getPageBySlug(slug: string): Promise<Page | undefined> {
|
||||||
|
return this._pages.find((p) => p.slug === slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getPages(options?: {
|
||||||
|
status?: string;
|
||||||
|
limit?: number;
|
||||||
|
offset?: number;
|
||||||
|
}): Promise<Page[]> {
|
||||||
|
let result = [...this._pages];
|
||||||
|
if (options?.status) {
|
||||||
|
result = result.filter((p) => p.status === options.status);
|
||||||
|
}
|
||||||
|
const offset = options?.offset ?? 0;
|
||||||
|
const limit = options?.limit ?? 50;
|
||||||
|
return result.slice(offset, offset + limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import "reflect-metadata";
|
||||||
|
import { injectable } from "inversify";
|
||||||
|
|
||||||
|
import type { ISiteSettingsRepository } from "../../application/repositories/site-settings-repository.interface";
|
||||||
|
import type { SiteSettings } from "../../entities/site-settings";
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class MockSiteSettingsRepository implements ISiteSettingsRepository {
|
||||||
|
async getSiteSettings(): Promise<SiteSettings> {
|
||||||
|
return {
|
||||||
|
siteName: "My App",
|
||||||
|
siteDescription: "A vertical-feature monorepo template",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user