Skip to content

Commit

Permalink
🏷️ (api): Add ApiResponse type globally
Browse files Browse the repository at this point in the history
  • Loading branch information
toridoriv committed Oct 3, 2023
1 parent 90b1582 commit a882d18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions server/@global.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import type { express, Fanfictions, Logger } from "@deps";
import type { express, Logger } from "@deps";
import { databaseClient } from "./database.ts";
import { GenericApiResponse } from "./api/@endpoint.ts";
import { AnyApiResponse } from "./api/@endpoint.ts";

declare global {
function fetch(input: "./api/fanfictions"): Promise<{
json: () => Promise<GenericApiResponse<Fanfictions.Fanfiction[]>>;
}>;
/**
* Instead of adding a `disable` directive, use this value
* to indicate that an any type is expected that way purposely.
*/
// deno-lint-ignore no-explicit-any
type SafeAny = any;

export type ApiResponseType<T = unknown> = AnyApiResponse<T>;

namespace Express {
interface Application {
db: typeof databaseClient;
Expand Down
2 changes: 2 additions & 0 deletions server/api/@endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ export type AnyPayload = z.ZodObject<
*/
export type AnyEndpoint = ApiEndpoint<SafeAny, SafeAny>;

export type AnyApiResponse<T> = ApiResponse<T>;

// #endregion

/* -------------------------------------------------------------------------- */
Expand Down

0 comments on commit a882d18

Please sign in to comment.