Compare commits
2 Commits
1132bfd129
...
dfb924bb3f
Author | SHA1 | Date |
---|---|---|
Ferdinand Thiessen | dfb924bb3f | |
Ferdinand Thiessen | bc9dba1c7b |
|
@ -75,7 +75,11 @@ module.exports = {
|
||||||
|
|
||||||
// add your custom rules here
|
// add your custom rules here
|
||||||
rules: {
|
rules: {
|
||||||
'prefer-promise-reject-errors': 'off',
|
// VueStuff
|
||||||
|
'vue/multi-word-component-names': 'off',
|
||||||
|
|
||||||
|
// Misc
|
||||||
|
'prefer-promise-reject-errors': ["error", {"allowEmptyReject": true}],
|
||||||
|
|
||||||
// TypeScript
|
// TypeScript
|
||||||
quotes: ['warn', 'single', { avoidEscape: true }],
|
quotes: ['warn', 'single', { avoidEscape: true }],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "1.0.0-alpha.1",
|
"version": "1.0.0-alpha.2",
|
||||||
"name": "@flaschengeist/api",
|
"name": "@flaschengeist/api",
|
||||||
"author": "Tim Gröger <flaschengeist@wu5.de>",
|
"author": "Tim Gröger <flaschengeist@wu5.de>",
|
||||||
"homepage": "https://flaschengeist.dev/Flaschengeist",
|
"homepage": "https://flaschengeist.dev/Flaschengeist",
|
||||||
|
@ -19,21 +19,21 @@
|
||||||
"pinia": "^2.0.0-alpha.19"
|
"pinia": "^2.0.0-alpha.19"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@flaschengeist/types": "^1.0.0-alpha.1",
|
"@flaschengeist/types": "^1.0.0-alpha.4",
|
||||||
"@types/node": "^12.20.13",
|
"@types/node": "^12.20.37",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.24.0",
|
"@typescript-eslint/eslint-plugin": "^5.3.1",
|
||||||
"@typescript-eslint/parser": "^4.24.0",
|
"@typescript-eslint/parser": "^5.3.1",
|
||||||
"eslint": "^7.26.0",
|
"eslint": "^8.2.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-vue": "^7.9.0",
|
"eslint-plugin-vue": "^8.0.3",
|
||||||
"eslint-webpack-plugin": "^2.5.4",
|
"eslint-webpack-plugin": "^3.1.0",
|
||||||
"prettier": "^2.3.0",
|
"prettier": "^2.4.1",
|
||||||
"typescript": "^4.2.4"
|
"typescript": "^4.4.4"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"semi": true,
|
"semi": true,
|
||||||
"printWidth": 120,
|
"printWidth": 100,
|
||||||
"arrowParens": "always"
|
"arrowParens": "always"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
import { AxiosError } from 'axios';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if error is an AxiosError, and optional if a specific status was returned
|
||||||
|
*
|
||||||
|
* @param error Thrown error to check
|
||||||
|
* @param status If set, check if this error has set thouse status code
|
||||||
|
*/
|
||||||
|
export function isAxiosError(error: unknown, status?: number) {
|
||||||
|
// Check if it is an axios error (with axios 1.0 `error instanceof AxiosError` will be possible)
|
||||||
|
if (!error || typeof error !== 'object' || !('isAxiosError' in <object>error)) return false;
|
||||||
|
// Check status code if status was given
|
||||||
|
if (status !== undefined)
|
||||||
|
return (
|
||||||
|
(<AxiosError>error).response !== undefined && (<AxiosError>error).response?.status === status
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
export * from './main';
|
export * from './main';
|
||||||
export * from './session';
|
export * from './session';
|
||||||
export * from './user';
|
export * from './user';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { AxiosError, AxiosResponse } from 'axios';
|
import { AxiosResponse } from 'axios';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { api } from '../internal';
|
import { api } from '../internal';
|
||||||
import { useMainStore } from '.';
|
import { isAxiosError, useMainStore } from '.';
|
||||||
|
|
||||||
export const useSessionStore = defineStore({
|
export const useSessionStore = defineStore({
|
||||||
id: 'sessions',
|
id: 'sessions',
|
||||||
|
@ -46,8 +46,8 @@ export const useSessionStore = defineStore({
|
||||||
await api.delete(`/auth/${token}`);
|
await api.delete(`/auth/${token}`);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!error || !('response' in error) || (<AxiosError>error).response?.status != 401)
|
// Ignore 401, as this means we are already logged out, throw all other
|
||||||
throw error;
|
if (!isAxiosError(error, 401)) throw error;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { AxiosError } from 'axios';
|
|
||||||
import { api } from '../internal';
|
import { api } from '../internal';
|
||||||
import { useMainStore } from '.';
|
import { isAxiosError, useMainStore } from '.';
|
||||||
|
|
||||||
export const useUserStore = defineStore({
|
export const useUserStore = defineStore({
|
||||||
id: 'users',
|
id: 'users',
|
||||||
|
@ -30,8 +29,8 @@ export const useUserStore = defineStore({
|
||||||
else this.users[idx] = data;
|
else this.users[idx] = data;
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!error || !('response' in error) || (<AxiosError>error).response?.status !== 404)
|
// Ignore 404, throw all other
|
||||||
throw error;
|
if (!isAxiosError(error, 404)) throw error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return this.users[idx];
|
return this.users[idx];
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// THIS FEATURE-FLAG FILE IS AUTOGENERATED,
|
// THIS FEATURE-FLAG FILE IS AUTOGENERATED,
|
||||||
// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING
|
// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING
|
||||||
import "quasar/dist/types/feature-flag";
|
import 'quasar/dist/types/feature-flag';
|
||||||
|
|
||||||
declare module "quasar/dist/types/feature-flag" {
|
declare module 'quasar/dist/types/feature-flag' {
|
||||||
interface QuasarFeatureFlags {
|
interface QuasarFeatureFlags {
|
||||||
cordova: true;
|
cordova: true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// THIS FEATURE-FLAG FILE IS AUTOGENERATED,
|
// THIS FEATURE-FLAG FILE IS AUTOGENERATED,
|
||||||
// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING
|
// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING
|
||||||
import "quasar/dist/types/feature-flag";
|
import 'quasar/dist/types/feature-flag';
|
||||||
|
|
||||||
declare module "quasar/dist/types/feature-flag" {
|
declare module 'quasar/dist/types/feature-flag' {
|
||||||
interface QuasarFeatureFlags {
|
interface QuasarFeatureFlags {
|
||||||
electron: true;
|
electron: true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,7 @@ const config = {
|
||||||
pollingInterval: 30000,
|
pollingInterval: 30000,
|
||||||
};
|
};
|
||||||
|
|
||||||
const baseURL = computed(() =>
|
const baseURL = computed(() => LocalStorage.getItem<string>('baseURL') || config.baseURL);
|
||||||
LocalStorage.getItem<string>('baseURL') || config.baseURL
|
|
||||||
);
|
|
||||||
|
|
||||||
export {baseURL}
|
export { baseURL };
|
||||||
export default config;
|
export default config;
|
||||||
|
|
Loading…
Reference in New Issue