restructure and reorganize
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
|
||||
export async function fetchAuthRedirectUri(api_url: string): Promise<{
|
||||
uri: string;
|
||||
callbackKey: string;
|
||||
}> {
|
||||
const client: AxiosInstance = axios.create({
|
||||
baseURL: api_url || "",
|
||||
timeout: 5000,
|
||||
});
|
||||
try {
|
||||
const res = await client.get("/v1/auth/uri");
|
||||
const d = res.data ?? {};
|
||||
const uri = d.data.uri;
|
||||
const callbackKey = d.data.callbackKey;
|
||||
if (typeof uri !== "string" || !uri)
|
||||
throw new Error("redirect uri missing from response");
|
||||
return {
|
||||
uri,
|
||||
callbackKey,
|
||||
};
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Failed to fetch auth redirect uri: ${(e as Error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
+9
-4
@@ -1,10 +1,15 @@
|
||||
// place files you want to import through the `$lib` alias in this folder.
|
||||
|
||||
export * from "./axios";
|
||||
export * from "./user";
|
||||
export * from "./companies";
|
||||
export * from "./credentialTypes";
|
||||
import { user } from "./optima-api/modules/user";
|
||||
|
||||
export const optima = {
|
||||
auth: (await import("./optima-api/modules/auth")).auth,
|
||||
company: (await import("./optima-api/modules/companies")).company,
|
||||
credential: (await import("./optima-api/modules/credentials")).credential,
|
||||
credentialType: (await import("./optima-api/modules/credentialTypes"))
|
||||
.credentialType,
|
||||
user,
|
||||
};
|
||||
/**
|
||||
* @TODO
|
||||
*
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
|
||||
export const auth = {
|
||||
async fetchAuthRedirectUri(api_url: string): Promise<{
|
||||
uri: string;
|
||||
callbackKey: string;
|
||||
}> {
|
||||
const client: AxiosInstance = axios.create({
|
||||
baseURL: api_url || "",
|
||||
timeout: 5000,
|
||||
});
|
||||
try {
|
||||
const res = await client.get("/v1/auth/uri");
|
||||
const d = res.data ?? {};
|
||||
const uri = d.data.uri;
|
||||
const callbackKey = d.data.callbackKey;
|
||||
if (typeof uri !== "string" || !uri)
|
||||
throw new Error("redirect uri missing from response");
|
||||
return {
|
||||
uri,
|
||||
callbackKey,
|
||||
};
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Failed to fetch auth redirect uri: ${(e as Error).message}`,
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import api from "./axios";
|
||||
import api from "../axios";
|
||||
|
||||
export const company = {
|
||||
async fetch(accessToken: string, id: string) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import api from "./axios";
|
||||
import api from "../axios";
|
||||
|
||||
export interface CredentialTypeField {
|
||||
id: string;
|
||||
@@ -1,4 +1,4 @@
|
||||
import api from "./axios";
|
||||
import api from "../axios";
|
||||
|
||||
export interface CredentialField {
|
||||
id: string;
|
||||
Reference in New Issue
Block a user