Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { CommonRemoteDataServices } from '@repo/core-api/data-services';
|
||||
import type { BaseEntity } from '@repo/core-api/data-services';
|
||||
import { publicClient } from '../../../lib/api-client';
|
||||
|
||||
// ─── Domain Entity ──────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Public content entity for the landing page.
|
||||
*
|
||||
* Represents promotional content, blog posts, or announcements
|
||||
* served from a public API without authentication.
|
||||
*/
|
||||
export interface PublicContentEntity extends BaseEntity {
|
||||
title: string;
|
||||
slug: string;
|
||||
excerpt: string;
|
||||
imageUrl: string;
|
||||
publishedAt: string;
|
||||
}
|
||||
|
||||
// ─── Data Services Instance ─────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Public content data services — wired to the lightweight `publicClient`.
|
||||
*
|
||||
* No auth, no OTel — pure zero-overhead HTTP calls.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const { data } = await publicContentServices.getMany();
|
||||
* const { data: post } = await publicContentServices.getOne('hello-world');
|
||||
* ```
|
||||
*/
|
||||
export const publicContentServices = new CommonRemoteDataServices<PublicContentEntity>(
|
||||
publicClient,
|
||||
{
|
||||
apiUrl: '/content',
|
||||
moduleKey: 'PUBLIC_CONTENT',
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user