Skip to main content
Home
This release is 6 versions behind 3.0.5 — the latest version of @aneuhold/core-ts-api-lib. Jump to latest

Built and signed on GitHub Actions

A library for interacting with the backend and defining the backend API for personal projects.

This package works with Node.js, Deno, Browsers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
100%
Published
a month ago (2.2.8)
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); } }