This commit is contained in:
Julian Freeman
2025-12-01 08:41:44 -04:00
parent c7c7b5fc4b
commit ee586ae06f
5 changed files with 317 additions and 2 deletions

View File

@@ -8,6 +8,13 @@ export interface KeyValue {
enabled: boolean;
}
export interface AuthState {
type: 'none' | 'basic' | 'bearer' | 'api_key';
basic: { username: '', password: '' };
bearer: { token: '' };
apiKey: { key: '', value: '', addTo: 'header' | 'query' };
}
export interface RequestData {
id: string;
method: string;
@@ -15,6 +22,7 @@ export interface RequestData {
params: KeyValue[];
headers: KeyValue[];
body: string;
auth: AuthState;
response?: {
status: number;
headers: Record<string, string>;
@@ -39,6 +47,12 @@ export const useRequestStore = defineStore('request', () => {
{ id: crypto.randomUUID(), key: '', value: '', enabled: true }
],
body: '',
auth: {
type: 'none',
basic: { username: '', password: '' },
bearer: { token: '' },
apiKey: { key: '', value: '', addTo: 'header' }
},
timestamp: Date.now(),
});
@@ -81,6 +95,16 @@ export const useRequestStore = defineStore('request', () => {
if (loaded.params.length === 0) loaded.params.push({ id: crypto.randomUUID(), key: '', value: '', enabled: true });
if (loaded.headers.length === 0) loaded.headers.push({ id: crypto.randomUUID(), key: '', value: '', enabled: true });
// Ensure auth object exists (migration for old history)
if (!loaded.auth) {
loaded.auth = {
type: 'none',
basic: { username: '', password: '' },
bearer: { token: '' },
apiKey: { key: '', value: '', addTo: 'header' }
};
}
activeRequest.value = loaded;
};