refactor: restructure storage and environment modules; remove unused code

- Deleted unused PouchDB configuration and types from core storage.
- Removed Electron-related hooks and utilities that are no longer needed.
- Introduced new local storage management for application keys.
- Created a new environment wrapper for landing application.
- Added public HTTP client for landing application with minimal configuration.
- Implemented new PouchDB entities for items and POS configurations.
- Updated main application entry point to reflect new storage structure.
This commit is contained in:
Firman Ramdhani
2026-05-29 17:36:34 +07:00
parent b2e622c57e
commit 5d9f0f6d94
26 changed files with 233 additions and 197 deletions
+42
View File
@@ -0,0 +1,42 @@
import { createHttpClient } from '@repo/core-api/http-client';
import { faroAdapter } from '@repo/core-api/observability';
/**
* Enterprise HTTP client for `apps/web`.
*
* - Full Faro observability via the shared `faroAdapter`
* - Automatic Bearer token injection from localStorage
* - 401 redirect to `/auth/login`
* - Supports per-request `telemetryContext` for custom spans/tags
*
* All interceptors (auth, observability, error normalization)
* are baked into this instance. Import this singleton throughout
* the web application — never create raw axios instances.
*/
export const apiClient = createHttpClient(
{
baseURL: import.meta.env.VITE_API_URL ?? 'http://localhost:8080/api/v1',
timeout: 15000,
observability: faroAdapter,
},
{
// ── Auth Interceptor ──────────────────────────────────────────
onRequest: async (config) => {
const token = localStorage.getItem('access_token');
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
},
// ── Error Interceptor ─────────────────────────────────────────
onResponseError: async (error) => {
if (error.response?.status === 401) {
// Clear stale token and redirect to login
localStorage.removeItem('access_token');
window.location.href = '/auth/login';
}
throw error;
},
},
);