UNPKG

@follow-app/client-sdk

Version:

TypeScript client SDK for Follow RSS Server API

82 lines (71 loc) 2.01 kB
import type { SuccessResponse } from "@/types" import { defineModule, defineRoute } from "../../shared/define-module" import type { CheckNewEntriesQuery, CheckNewEntriesResponse, EntryGetByIdResponse, EntryGetQuery, EntryListRequest, EntryListResponse, EntryPreviewRequest, EntryPreviewResponse, EntryReadabilityRequest, EntryReadabilityResponse, EntryStreamRequest, InboxEntryGetQuery, InboxEntryGetResponse, InboxListEntryRequestInput, InboxListEntryResponse, InboxRemoveInput, ReadHistoriesInput, ReadHistoriesResponse, } from "./types" /** * Entries module definition with nested routes */ export const entriesModule = defineModule({ name: "entries", prefix: "/entries", routes: { // Basic entry operations get: defineRoute<EntryGetQuery, EntryGetByIdResponse>("GET", "/"), list: defineRoute<EntryListRequest, EntryListResponse>("POST", "/"), preview: defineRoute<EntryPreviewRequest, EntryPreviewResponse>( "POST", "/preview", ), readability: defineRoute<EntryReadabilityRequest, EntryReadabilityResponse>( "POST", "/readability", ), stream: defineRoute<EntryStreamRequest, Response>("POST", "/stream"), // Check for new entries checkNew: defineRoute<CheckNewEntriesQuery, CheckNewEntriesResponse>( "GET", "/check-new", ), // Read histories readHistories: defineRoute<ReadHistoriesInput, ReadHistoriesResponse>( "GET", "/{id}/read-histories", ), // Inbox operations (nested) inbox: { get: defineRoute<InboxEntryGetQuery, InboxEntryGetResponse>( "GET", "/inbox", ), list: defineRoute<InboxListEntryRequestInput, InboxListEntryResponse>( "POST", "/inbox", ), delete: defineRoute<InboxRemoveInput, SuccessResponse>( "DELETE", "/inbox", ), }, }, }) // Export the API type export type EntriesAPI = typeof entriesModule.api export type * from "./types"