Browse Source

Add template to paginated response in the search API package

dev
David Ludwig 4 years ago
parent
commit
24c3d58660
2 changed files with 5 additions and 5 deletions
  1. +3
    -3
      api/search/src/IpcClient.ts
  2. +2
    -2
      api/search/src/schema.ts

+ 3
- 3
api/search/src/IpcClient.ts View File

@ -1,7 +1,7 @@
import { IpcClientService } from "@autoplex/ipc";
import { Microservice } from "@autoplex/microservice";
import { SOCKET_PATH } from "./constants";
import { IMovie, IMovieDetails } from "./schema";
import { IMovie, IMovieDetails, IPaginatedResponse } from "./schema";
export class IpcClient<M extends Microservice = Microservice> extends IpcClientService<M>
{
@ -36,7 +36,7 @@ export class IpcClient<M extends Microservice = Microservice> extends IpcClientS
console.error("Failed to find a movie by its IMDb ID:", result.error);
throw new Error("Failed to find a movie by its IMDb ID");
}
return <IMovie>result.data;
return <IMovie|null>result.data;
}
/**
@ -48,7 +48,7 @@ export class IpcClient<M extends Microservice = Microservice> extends IpcClientS
console.error("Failed to search for a movie:", result.error);
throw new Error("Failed to search for a movie");
}
return <IMovie>result.data;
return <IPaginatedResponse<IMovie>>result.data;
}
/**


+ 2
- 2
api/search/src/schema.ts View File

@ -33,9 +33,9 @@ export interface IMovieDetails extends IMovie {
tagline : string | null
}
export interface IPaginatedResponse {
export interface IPaginatedResponse<T> {
page : number,
results : IMovie[],
results : T[],
totalResults: number,
totalPages : number
}

Loading…
Cancel
Save