This release is 6 versions behind 3.0.5 — the latest version of @aneuhold/core-ts-api-lib. Jump to latest
@aneuhold/core-ts-api-lib@2.2.8Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
A library for interacting with the backend and defining the backend API for personal projects.
import type { APIResponse } from '../../types/APIResponse.ts'; import type { AuthValidateUserInput, AuthValidateUserOutput } from '../DOFunctionService/functions/authValidateUser.ts'; import type { ProjectDashboardInput, ProjectDashboardOutput } from '../DOFunctionService/functions/projectDashboard.ts'; import GCloudAPIService from '../GCloudAPIService/GCloudAPIService.ts'; /** * A service for making calls to the backend API for personal projects. This is * abstracted so that the backend implementation can change over time. */ export default class APIService { /** * Validates the provided username and password against the database and * returns the user's information if successful. * * @param input - The input containing username and password. * @returns A promise that resolves to the user's information if validation is successful. */ static async validateUser( input: AuthValidateUserInput ): Promise<APIResponse<AuthValidateUserOutput>> { return await GCloudAPIService.authValidateUser(input); } /** * Calls the dashboard API and returns the result. This will fail if the * dashboard API URL has not been set. See {@link setDashboardAPIUrl}. * * @param input - The input for the dashboard API call. * @returns A promise that resolves to the result of the dashboard API call. */ static async callDashboardAPI( input: ProjectDashboardInput ): Promise<APIResponse<ProjectDashboardOutput>> { return GCloudAPIService.projectDashboard(input); } /** * Sets the base URL for the API. * * @param url - The URL to be set for the API. This should include a trailing slash. */ static setAPIUrl(url: string) { GCloudAPIService.setUrl(url); } }