UNPKG

@mathrunet/masamune

Version:

Manages packages for the server portion (NodeJS) of the Masamune framework.

186 lines (185 loc) 5 kB
import { Response as ApiResponse, HeadersInit as ApiHeaders } from "node-fetch"; export { Response as ApiResponse, HeadersInit as ApiHeaders } from "node-fetch"; /** * API for Rest can be called. * * Rest用のAPIを呼び出すことができます。 */ export declare abstract class Api { /** * Call the API with the `GET` parameter. * * `GET`パラメーターでAPIを呼び出します。 * * @param {string} url * The URL of the API to call. * * 呼び出すAPIのURL。 * * @param {GetRequestOptions | undefined} options * Options for `GET` requests. * * `GET`リクエスト用のオプション。 * * @returns {Promise<ApiResponse>} * Response from API. * * APIからのレスポンス。 */ static get(url: string, options?: GetRequestOptions | undefined): Promise<ApiResponse>; /** * Call the API with the `POST` parameter. * * `POST`パラメーターでAPIを呼び出します。 * * @param {string} url * The URL of the API to call. * * 呼び出すAPIのURL。 * * @param {PostRequestOptions | undefined} options * Options for `POST` requests. * * `POST`リクエスト用のオプション。 * * @returns {Promise<ApiResponse>} * Response from API. * * APIからのレスポンス。 */ static post(url: string, options?: PostRequestOptions | undefined): Promise<ApiResponse>; /** * Call the API with the `PUT` parameter. * * `PUT`パラメーターでAPIを呼び出します。 * * @param {string} url * The URL of the API to call. * * 呼び出すAPIのURL。 * * @param {PutRequestOptions | undefined} options * Options for `PUT` requests. * * `PUT`リクエスト用のオプション。 * * @returns {Promise<ApiResponse>} * Response from API. * * APIからのレスポンス。 */ static put(url: string, options?: PutRequestOptions | undefined): Promise<ApiResponse>; /** * Call the API with the `DELETE` parameter. * * `DELETE`パラメーターでAPIを呼び出します。 * * @param {string} url * The URL of the API to call. * * 呼び出すAPIのURL。 * * @param {DeleteRequestOptions | undefined} options * Options for `DELETE` requests. * * `DELETE`リクエスト用のオプション。 * * @returns {Promise<ApiResponse>} * Response from API. * * APIからのレスポンス。 */ static delete(url: string, options?: DeleteRequestOptions | undefined): Promise<ApiResponse>; } /** * Options for `GET` requests. * * `GET`リクエスト用のオプション。 * * @param {ApiHeaders | undefined} headers * Header information to be sent to the API. * * APIに送信するヘッダー情報。 * * @param {number | undefined} timeout * Timeout time for API call. * * API呼び出しのタイムアウト時間。 */ export interface GetRequestOptions { headers?: ApiHeaders | undefined; timeout?: number | undefined; } /** * Options for `POST` requests. * * `POST`リクエスト用のオプション。 * * @param {ApiHeaders | undefined} headers * Header information to be sent to the API. * * APIに送信するヘッダー情報。 * * @param {number | undefined} timeout * Timeout time for API call. * * API呼び出しのタイムアウト時間。 * * @param {data: { [key: string]: any } | string | undefined} * Data to be sent to the API. * * APIに送信するデータ。 */ export interface PostRequestOptions { headers?: ApiHeaders | undefined; timeout?: number | undefined; data: { [key: string]: any; } | string | undefined; } /** * Options for `PUT` requests. * * `PUT`リクエスト用のオプション。 * * @param {ApiHeaders | undefined} headers * Header information to be sent to the API. * * APIに送信するヘッダー情報。 * * @param {number | undefined} timeout * Timeout time for API call. * * API呼び出しのタイムアウト時間。 * * @param {data: { [key: string]: any } | string | undefined} * Data to be sent to the API. * * APIに送信するデータ。 */ export interface PutRequestOptions { headers?: ApiHeaders | undefined; timeout?: number | undefined; data: { [key: string]: any; } | string | undefined; } /** * Options for `DELETE` requests. * * `DELETE`リクエスト用のオプション。 * * @param {ApiHeaders | undefined} headers * Header information to be sent to the API. * * APIに送信するヘッダー情報。 * * @param {number | undefined} timeout * Timeout time for API call. * * API呼び出しのタイムアウト時間。 */ export interface DeleteRequestOptions { headers?: ApiHeaders | undefined; timeout?: number | undefined; }