mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
create a generic service type
This commit is contained in:
parent
36ecf8c06b
commit
a94b5d21ec
@ -20,3 +20,8 @@ export interface CollectionTypeService extends BaseService {
|
||||
|
||||
export type Service = SingleTypeService | CollectionTypeService;
|
||||
|
||||
export type GenericService = Partial<Service> & {
|
||||
[method: string | number | symbol]: (...args:unknown) => Promise<Entity> | Entity;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Service } from '../core-api/service';
|
||||
import { Service,GenericService } from '../core-api/service';
|
||||
import { Controller, GenericController } from '../core-api/controller';
|
||||
import { Middleware } from '../middlewares';
|
||||
import { Policy } from '../core/registries/policies';
|
||||
@ -47,14 +47,14 @@ interface Router {
|
||||
type ControllerCallback<T extends GenericController = GenericController> = (params: {
|
||||
strapi: Strapi;
|
||||
}) => T;
|
||||
type ServiceCallback<T extends Service = Service> = (params: { strapi: Strapi }) => T;
|
||||
type ServiceCallback<T extends GenericService = GenericService> = (params: { strapi: Strapi }) => T;
|
||||
|
||||
export function createCoreRouter(uid: string, cfg?: RouterConfig = {}): () => Router;
|
||||
export function createCoreController<T extends GenericController = GenericController>(
|
||||
uid: string,
|
||||
cfg?: ControllerCallback<T> | T = {}
|
||||
): () => T & Controller;
|
||||
export function createCoreService<T extends Service = Service>(
|
||||
export function createCoreService<T extends GenericService = GenericService>(
|
||||
uid: string,
|
||||
cfg?: ServiceCallback<T> | T = {}
|
||||
): () => T;
|
||||
|
Loading…
x
Reference in New Issue
Block a user