@3kjos/fortress
Version:
3kjos fortress is an authentification ecosystem.
59 lines (51 loc) • 2.38 kB
text/typescript
import { AxiosRequestConfig } from "axios";
import { PropsWithChildren } from "react";
// Interface
export interface FortressProps {
// Define your component props here
base_route_url: string | URL;
base_api_route_url?: string | URL;
ping_route_url: string;
csrf_cookies_route_url?: string | undefined;
allowed_path?: string[];
after_login_path?: string;
disallowed_path?: string[];
login_path: string;
signup_path: string;
desallowed_redirect_path?: string;
session_storage_name?: string;
http_request_config?: AxiosRequestConfig<any> | undefined;
}
export interface FortressEntryProps extends PropsWithChildren<ConfigInterface> {
// Define your component props here
}
export interface HttpHeaderInterface {
"Content-Type"?: "application/json" | "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain" | "text/html " | "application/octet-stream" | "application/zip" | "application/pdf" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation";
"accept"?: "application/json";
"Authorization"?: string;
}
export interface HttpConfigInterface {
method: HttpMethodsType | undefined;
headers: HttpHeaderInterface | undefined;
body: string;
timeout?: number;
retries?: number;
credentials?: "same-origin" | "include" | "omit" | "credentials";
redirect?: "follow" | "manual" | "error";
referrerPolicy?: "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
}
export interface ConfigInterface {
config: FortressProps
}
export interface UseFortressHttpInterface {
httpPost: UseFortressHttpFunctionType, httpGet: UseFortressHttpFunctionType, httpPut: UseFortressHttpFunctionType, httpDelete: UseFortressHttpFunctionType, httpSubmitForm: UseFortressHttpPropsInterface
}
export type UseFortressHttpPropsInterface = (
route_url: string,
data: object
) => Promise<void>;
// Types
export type HttpMethodsType = "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
export type UrlType = RequestInfo | URL
export type ConfigType = FortressProps;
export type UseFortressHttpFunctionType = (url: string, data: object) => Promise<any|void>