Skip to content

Commit

Permalink
test branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Meng-20 committed Dec 12, 2024
1 parent 1b634df commit d490c6f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
30 changes: 30 additions & 0 deletions webui/src/common/CustomApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates
import axios, { AxiosInstance } from 'axios';
import { DefaultApi } from "@/axios/api";
import type { Configuration } from '@/axios/configuration';
import https from 'https';
import fs from 'fs';

// Load the certificate
const cert = fs.readFileSync('/usr/local/share/ca-certificates/github_com_seagate_cfm-self-signed.crt');
// Use API_BASE_PATH to overwrite the BASE_PATH in the generated client code
const API_BASE_PATH = process.env.BASE_PATH;

// Create a custom Axios instance with HTTPS configuration
const axiosInstance: AxiosInstance = axios.create({
baseURL: API_BASE_PATH,
httpsAgent: new https.Agent({
ca: cert,
rejectUnauthorized: false,
}),
headers: {
'Content-Type': 'application/json',
}
});

// Extend the DefaultApi class to use the custom Axios instance
export class CustomApi extends DefaultApi {
constructor(configuration?: Configuration, basePath?: string) {
super(configuration, basePath, axiosInstance);
}
}
12 changes: 8 additions & 4 deletions webui/src/components/Stores/ServiceStore.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates
import { defineStore } from 'pinia'
import { DefaultApi } from "@/axios/api";
import { BASE_PATH } from "@/axios/base";
//import { DefaultApi } from "@/axios/api";
//import { BASE_PATH } from "@/axios/base";
import { CustomApi } from "@/common/CustomApi"
import { Configuration } from '@/axios';

// Use API_BASE_PATH to overwrite the BASE_PATH in the generated client code
const API_BASE_PATH = process.env.BASE_PATH || BASE_PATH;
//const API_BASE_PATH = process.env.BASE_PATH || BASE_PATH as ConfigurationParameters | undefined;

export const useServiceStore = defineStore('cfm-service', {
state: () => ({
Expand All @@ -13,7 +15,9 @@ export const useServiceStore = defineStore('cfm-service', {
actions: {
async getServiceVersion() {
try {
const defaultApi = new DefaultApi(undefined, API_BASE_PATH);
const config = new Configuration;
config.basePath = "https://localhost:8080"
const defaultApi = new CustomApi(config);
const response = await defaultApi.cfmV1Get();
this.serviceVersion = response.data.version;
} catch (error) {
Expand Down

0 comments on commit d490c6f

Please sign in to comment.