@raxonltd/raxon-core 1.1.8 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/context/security.context.tsx +9 -5
- package/core/feature/address/api/places.api.ts +20 -4
- package/core/feature/auth/hook/use.auth.tsx +7 -6
- package/core/feature/cart/hook/use.cart.tsx +3 -0
- package/core/raxon.context.tsx +7 -0
- package/core/server/places.proxy.ts +35 -0
- package/core/server/raxon.bootstrap.route.ts +39 -0
- package/core/server/raxon.server.ts +80 -0
- package/core/util/nexine.axios.tsx +3 -2
- package/core/util/storage.keys.ts +39 -0
- package/dist/core/context/security.context.d.ts.map +1 -1
- package/dist/core/context/security.context.js +8 -5
- package/dist/core/feature/address/api/places.api.d.ts.map +1 -1
- package/dist/core/feature/address/api/places.api.js +18 -4
- package/dist/core/feature/auth/hook/use.auth.d.ts.map +1 -1
- package/dist/core/feature/auth/hook/use.auth.js +7 -6
- package/dist/core/raxon.context.d.ts +3 -1
- package/dist/core/raxon.context.d.ts.map +1 -1
- package/dist/core/raxon.context.js +5 -3
- package/dist/core/server/places.proxy.d.ts +10 -0
- package/dist/core/server/places.proxy.d.ts.map +1 -0
- package/dist/core/server/places.proxy.js +24 -0
- package/dist/core/server/raxon.bootstrap.route.d.ts +7 -0
- package/dist/core/server/raxon.bootstrap.route.d.ts.map +1 -0
- package/dist/core/server/raxon.bootstrap.route.js +27 -0
- package/dist/core/server/raxon.server.d.ts +24 -0
- package/dist/core/server/raxon.server.d.ts.map +1 -0
- package/dist/core/server/raxon.server.js +59 -0
- package/dist/core/util/nexine.axios.d.ts.map +1 -1
- package/dist/core/util/nexine.axios.js +3 -2
- package/dist/core/util/storage.keys.d.ts +9 -0
- package/dist/core/util/storage.keys.d.ts.map +1 -0
- package/dist/core/util/storage.keys.js +35 -0
- package/dist/middleware.d.ts +6 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +5 -0
- package/dist/server-bootstrap.d.ts +2 -0
- package/dist/server-bootstrap.d.ts.map +1 -0
- package/dist/server-bootstrap.js +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -1
|
@@ -9,6 +9,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
|
9
9
|
import { useSecurityState } from "./context/security.context";
|
|
10
10
|
import { useCartState } from "./context/cart.context";
|
|
11
11
|
import { AnalyticEventProvider } from "./feature/analytic-event/analytic.event.context";
|
|
12
|
+
import { DEFAULT_STORAGE_PREFIX } from "./util/storage.keys";
|
|
12
13
|
export const RaxonContext = createContext(undefined);
|
|
13
14
|
function normalizeBootstrapPayload(raxon) {
|
|
14
15
|
if (!raxon)
|
|
@@ -43,7 +44,7 @@ function normalizeBootstrapPayload(raxon) {
|
|
|
43
44
|
brand: raxon.brand ?? [],
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
|
-
const RaxonProviderInner = ({ children, apiKey, apiUrl, productPathPrefix, analyticAutoTrack, bootstrapUrl = "/api/bootstrap", initialBootstrapData = null, }) => {
|
|
47
|
+
const RaxonProviderInner = ({ children, apiKey, apiUrl, storagePrefix = DEFAULT_STORAGE_PREFIX, productPathPrefix, analyticAutoTrack, bootstrapUrl = "/api/bootstrap", initialBootstrapData = null, }) => {
|
|
47
48
|
const initialNormalized = useMemo(() => normalizeBootstrapPayload(initialBootstrapData), [initialBootstrapData]);
|
|
48
49
|
const [raxon, setRaxon] = useState(initialBootstrapData ?? null);
|
|
49
50
|
const [isLoading, setIsLoading] = useState(!initialNormalized);
|
|
@@ -53,6 +54,7 @@ const RaxonProviderInner = ({ children, apiKey, apiUrl, productPathPrefix, analy
|
|
|
53
54
|
if (typeof window !== "undefined") {
|
|
54
55
|
window.__RAXON_API_KEY__ = apiKey;
|
|
55
56
|
window.__RAXON_API_URL__ = apiUrl;
|
|
57
|
+
window.__RAXON_STORAGE_PREFIX__ = storagePrefix;
|
|
56
58
|
nexineAxios.defaults.baseURL = apiUrl;
|
|
57
59
|
nexineAxios.defaults.headers.common["x-api-key"] = apiKey;
|
|
58
60
|
}
|
|
@@ -112,9 +114,9 @@ const RaxonProviderInner = ({ children, apiKey, apiUrl, productPathPrefix, analy
|
|
|
112
114
|
}), [normalized, isLoading, profile, authLoading, isAuthenticated, isGuest, cartState]);
|
|
113
115
|
return (_jsxs(RaxonContext.Provider, { value: value, children: [_jsx(AnalyticEventProvider, { productPathPrefix: productPathPrefix, autoTrack: analyticAutoTrack, children: children }), _jsx(ModalAuth, { ref: modalAuthRef }), _jsx(ModalNewsletterVariantProduct, { ref: modalNewsletterVariantProductRef })] }));
|
|
114
116
|
};
|
|
115
|
-
export const RaxonProvider = ({ children, apiKey, apiUrl, productPathPrefix, analyticAutoTrack, bootstrapUrl, initialBootstrapData, }) => {
|
|
117
|
+
export const RaxonProvider = ({ children, apiKey, apiUrl, storagePrefix, productPathPrefix, analyticAutoTrack, bootstrapUrl, initialBootstrapData, }) => {
|
|
116
118
|
const [queryClient] = useState(() => new QueryClient());
|
|
117
|
-
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(RaxonProviderInner, { apiKey: apiKey, apiUrl: apiUrl, productPathPrefix: productPathPrefix, analyticAutoTrack: analyticAutoTrack, bootstrapUrl: bootstrapUrl, initialBootstrapData: initialBootstrapData, children: children }) }));
|
|
119
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(RaxonProviderInner, { apiKey: apiKey, apiUrl: apiUrl, storagePrefix: storagePrefix, productPathPrefix: productPathPrefix, analyticAutoTrack: analyticAutoTrack, bootstrapUrl: bootstrapUrl, initialBootstrapData: initialBootstrapData, children: children }) }));
|
|
118
120
|
};
|
|
119
121
|
export const useRaxon = () => {
|
|
120
122
|
const context = useContext(RaxonContext);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import type { NextRequest } from 'next/server';
|
|
3
|
+
declare const GOOGLE_PLACES_URL: {
|
|
4
|
+
readonly autocomplete: "https://maps.googleapis.com/maps/api/place/autocomplete/json";
|
|
5
|
+
readonly details: "https://maps.googleapis.com/maps/api/place/details/json";
|
|
6
|
+
};
|
|
7
|
+
export type GooglePlacesEndpoint = keyof typeof GOOGLE_PLACES_URL;
|
|
8
|
+
export declare function proxyGooglePlaces(request: NextRequest, endpoint: GooglePlacesEndpoint, googleMapsApiKey?: string): Promise<NextResponse<any>>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=places.proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"places.proxy.d.ts","sourceRoot":"","sources":["../../../core/server/places.proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,QAAA,MAAM,iBAAiB;;;CAGb,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAElE,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,oBAAoB,EAC9B,gBAAgB,CAAC,EAAE,MAAM,8BAqB1B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
const GOOGLE_PLACES_URL = {
|
|
3
|
+
autocomplete: 'https://maps.googleapis.com/maps/api/place/autocomplete/json',
|
|
4
|
+
details: 'https://maps.googleapis.com/maps/api/place/details/json',
|
|
5
|
+
};
|
|
6
|
+
export async function proxyGooglePlaces(request, endpoint, googleMapsApiKey) {
|
|
7
|
+
const googleUrl = new URL(GOOGLE_PLACES_URL[endpoint]);
|
|
8
|
+
request.nextUrl.searchParams.forEach((value, key) => {
|
|
9
|
+
googleUrl.searchParams.set(key, value);
|
|
10
|
+
});
|
|
11
|
+
const apiKey = googleMapsApiKey ?? process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY ?? '';
|
|
12
|
+
if (!googleUrl.searchParams.has('key') && apiKey) {
|
|
13
|
+
googleUrl.searchParams.set('key', apiKey);
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const response = await fetch(googleUrl.toString());
|
|
17
|
+
const data = await response.json();
|
|
18
|
+
return NextResponse.json(data);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error('[raxonServer/places]', error);
|
|
22
|
+
return NextResponse.json({ error: 'Google Places API isteği başarısız' }, { status: 500 });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
/** API route kullanmak isteyenler için: export { GET, revalidate } from '@raxonltd/raxon-core/server/bootstrap' */
|
|
3
|
+
export declare const revalidate = 300;
|
|
4
|
+
export declare function GET(): Promise<NextResponse<import("../..").RaxonBootstrapPayload> | NextResponse<{
|
|
5
|
+
error: string;
|
|
6
|
+
}>>;
|
|
7
|
+
//# sourceMappingURL=raxon.bootstrap.route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raxon.bootstrap.route.d.ts","sourceRoot":"","sources":["../../../core/server/raxon.bootstrap.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAyB3C,mHAAmH;AACnH,eAAO,MAAM,UAAU,MAA+B,CAAC;AAEvD,wBAAsB,GAAG;;IAUxB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import { unstable_cache } from 'next/cache';
|
|
3
|
+
import { fetchRaxonBootstrap } from '../util/fetch.bootstrap';
|
|
4
|
+
import { BOOTSTRAP_REVALIDATE_SECONDS, bootstrapCacheHeaders, } from '../server/raxon.server';
|
|
5
|
+
async function fetchBootstrapData() {
|
|
6
|
+
const apiUrl = process.env.NEXT_PUBLIC_API_URL;
|
|
7
|
+
const apiKey = process.env.NEXT_PUBLIC_API_KEY;
|
|
8
|
+
if (!apiUrl || !apiKey) {
|
|
9
|
+
throw new Error('[raxonServer] NEXT_PUBLIC_API_URL veya NEXT_PUBLIC_API_KEY tanımlı değil');
|
|
10
|
+
}
|
|
11
|
+
return fetchRaxonBootstrap(apiUrl, apiKey);
|
|
12
|
+
}
|
|
13
|
+
const getCachedBootstrap = unstable_cache(fetchBootstrapData, ['raxon-bootstrap'], { revalidate: BOOTSTRAP_REVALIDATE_SECONDS });
|
|
14
|
+
/** API route kullanmak isteyenler için: export { GET, revalidate } from '@raxonltd/raxon-core/server/bootstrap' */
|
|
15
|
+
export const revalidate = BOOTSTRAP_REVALIDATE_SECONDS;
|
|
16
|
+
export async function GET() {
|
|
17
|
+
try {
|
|
18
|
+
const data = await getCachedBootstrap();
|
|
19
|
+
return NextResponse.json(data, {
|
|
20
|
+
headers: bootstrapCacheHeaders(revalidate),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error('[raxonServer]', error);
|
|
25
|
+
return NextResponse.json({ error: 'Bootstrap verisi alınamadı' }, { status: 502 });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import type { NextRequest } from 'next/server';
|
|
3
|
+
declare const DEFAULT_REVALIDATE_SECONDS = 300;
|
|
4
|
+
export interface RaxonServerOptions {
|
|
5
|
+
apiUrl?: string;
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
googleMapsApiKey?: string;
|
|
8
|
+
revalidate?: number;
|
|
9
|
+
}
|
|
10
|
+
declare function bootstrapCacheHeaders(revalidate?: number): {
|
|
11
|
+
'Cache-Control': string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Next.js middleware — bootstrap ve Google Places BFF isteklerini karşılar.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // proxy.ts — config Next.js tarafından statik parse edilmeli, import edilemez
|
|
18
|
+
* import { raxonServer } from '@raxonltd/raxon-core/server';
|
|
19
|
+
* export default raxonServer();
|
|
20
|
+
* export const config = { matcher: ['/api/bootstrap', '/api/places/:path'] };
|
|
21
|
+
*/
|
|
22
|
+
export declare function raxonServer(options?: RaxonServerOptions): (request: NextRequest) => Promise<NextResponse<any>>;
|
|
23
|
+
export { DEFAULT_REVALIDATE_SECONDS as BOOTSTRAP_REVALIDATE_SECONDS, bootstrapCacheHeaders };
|
|
24
|
+
//# sourceMappingURL=raxon.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raxon.server.d.ts","sourceRoot":"","sources":["../../../core/server/raxon.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,QAAA,MAAM,0BAA0B,MAAM,CAAC;AAQvC,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkBD,iBAAS,qBAAqB,CAAC,UAAU,SAA6B;;EAIrE;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,IAGpB,SAAS,WAAW,gCAuB3D;AAED,OAAO,EAAE,0BAA0B,IAAI,4BAA4B,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import { fetchRaxonBootstrap } from '../util/fetch.bootstrap';
|
|
3
|
+
import { proxyGooglePlaces } from '../server/places.proxy';
|
|
4
|
+
const DEFAULT_REVALIDATE_SECONDS = 300;
|
|
5
|
+
const RAXON_SERVER_PATHS = {
|
|
6
|
+
bootstrap: '/api/bootstrap',
|
|
7
|
+
placesAutocomplete: '/api/places/autocomplete',
|
|
8
|
+
placesDetails: '/api/places/details',
|
|
9
|
+
};
|
|
10
|
+
function resolveCredentials(options = {}) {
|
|
11
|
+
const apiUrl = options.apiUrl ?? process.env.NEXT_PUBLIC_API_URL;
|
|
12
|
+
const apiKey = options.apiKey ?? process.env.NEXT_PUBLIC_API_KEY;
|
|
13
|
+
return { apiUrl, apiKey };
|
|
14
|
+
}
|
|
15
|
+
async function fetchBootstrapData(options = {}) {
|
|
16
|
+
const { apiUrl, apiKey } = resolveCredentials(options);
|
|
17
|
+
if (!apiUrl || !apiKey) {
|
|
18
|
+
throw new Error('[raxonServer] NEXT_PUBLIC_API_URL veya NEXT_PUBLIC_API_KEY tanımlı değil');
|
|
19
|
+
}
|
|
20
|
+
return fetchRaxonBootstrap(apiUrl, apiKey);
|
|
21
|
+
}
|
|
22
|
+
function bootstrapCacheHeaders(revalidate = DEFAULT_REVALIDATE_SECONDS) {
|
|
23
|
+
return {
|
|
24
|
+
'Cache-Control': `public, s-maxage=${revalidate}, stale-while-revalidate=${revalidate * 2}`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Next.js middleware — bootstrap ve Google Places BFF isteklerini karşılar.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // proxy.ts — config Next.js tarafından statik parse edilmeli, import edilemez
|
|
32
|
+
* import { raxonServer } from '@raxonltd/raxon-core/server';
|
|
33
|
+
* export default raxonServer();
|
|
34
|
+
* export const config = { matcher: ['/api/bootstrap', '/api/places/:path'] };
|
|
35
|
+
*/
|
|
36
|
+
export function raxonServer(options = {}) {
|
|
37
|
+
const revalidate = options.revalidate ?? DEFAULT_REVALIDATE_SECONDS;
|
|
38
|
+
return async function raxonMiddleware(request) {
|
|
39
|
+
const { pathname } = request.nextUrl;
|
|
40
|
+
if (pathname === RAXON_SERVER_PATHS.bootstrap) {
|
|
41
|
+
try {
|
|
42
|
+
const data = await fetchBootstrapData(options);
|
|
43
|
+
return NextResponse.json(data, { headers: bootstrapCacheHeaders(revalidate) });
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error('[raxonServer/bootstrap]', error);
|
|
47
|
+
return NextResponse.json({ error: 'Bootstrap verisi alınamadı' }, { status: 502 });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (pathname === RAXON_SERVER_PATHS.placesAutocomplete) {
|
|
51
|
+
return proxyGooglePlaces(request, 'autocomplete', options.googleMapsApiKey);
|
|
52
|
+
}
|
|
53
|
+
if (pathname === RAXON_SERVER_PATHS.placesDetails) {
|
|
54
|
+
return proxyGooglePlaces(request, 'details', options.googleMapsApiKey);
|
|
55
|
+
}
|
|
56
|
+
return NextResponse.next();
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export { DEFAULT_REVALIDATE_SECONDS as BOOTSTRAP_REVALIDATE_SECONDS, bootstrapCacheHeaders };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexine.axios.d.ts","sourceRoot":"","sources":["../../../core/util/nexine.axios.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nexine.axios.d.ts","sourceRoot":"","sources":["../../../core/util/nexine.axios.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,+BAMtB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { toast } from 'react-hot-toast';
|
|
3
|
+
import { getToken, removeToken } from '../util/storage.keys';
|
|
3
4
|
export const nexineAxios = axios.create({
|
|
4
5
|
baseURL: typeof window !== 'undefined' ? window.__RAXON_API_URL__ : process.env.NEXT_PUBLIC_API_URL,
|
|
5
6
|
headers: {
|
|
@@ -31,7 +32,7 @@ nexineAxios.interceptors.request.use(config => {
|
|
|
31
32
|
config.baseURL = apiUrl;
|
|
32
33
|
}
|
|
33
34
|
if (typeof window !== 'undefined') {
|
|
34
|
-
const token =
|
|
35
|
+
const token = getToken();
|
|
35
36
|
if (token) {
|
|
36
37
|
config.headers.Authorization = `Bearer ${token}`;
|
|
37
38
|
}
|
|
@@ -67,7 +68,7 @@ nexineAxios.interceptors.response.use(response => {
|
|
|
67
68
|
const requestMethod = error.config?.method || '';
|
|
68
69
|
// Token'ı temizle
|
|
69
70
|
if (typeof window !== 'undefined') {
|
|
70
|
-
|
|
71
|
+
removeToken();
|
|
71
72
|
}
|
|
72
73
|
// /auth/me endpoint'inde toast gösterme (SecurityContext yönetiyor)
|
|
73
74
|
if (!requestUrl.includes('/auth/me')) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const DEFAULT_STORAGE_PREFIX = "raxon";
|
|
2
|
+
export declare const getStoragePrefix: () => string;
|
|
3
|
+
export declare const getTokenStorageKey: () => string;
|
|
4
|
+
export declare const getTokenChangedEventName: () => string;
|
|
5
|
+
export declare const getToken: () => string | null;
|
|
6
|
+
export declare const setToken: (token: string) => void;
|
|
7
|
+
export declare const removeToken: () => void;
|
|
8
|
+
export declare const dispatchTokenChanged: () => void;
|
|
9
|
+
//# sourceMappingURL=storage.keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.keys.d.ts","sourceRoot":"","sources":["../../../core/util/storage.keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,UAAU,CAAC;AAK9C,eAAO,MAAM,gBAAgB,QAAO,MAKnC,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,MAErC,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAAO,MAE3C,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAO,MAAM,GAAG,IAGpC,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,IAGxC,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,IAG9B,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,IAGvC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const DEFAULT_STORAGE_PREFIX = 'raxon';
|
|
2
|
+
const TOKEN_SUFFIX = '-token';
|
|
3
|
+
const TOKEN_CHANGED_SUFFIX = '-token-changed';
|
|
4
|
+
export const getStoragePrefix = () => {
|
|
5
|
+
if (typeof window !== 'undefined') {
|
|
6
|
+
return window.__RAXON_STORAGE_PREFIX__ || DEFAULT_STORAGE_PREFIX;
|
|
7
|
+
}
|
|
8
|
+
return DEFAULT_STORAGE_PREFIX;
|
|
9
|
+
};
|
|
10
|
+
export const getTokenStorageKey = () => {
|
|
11
|
+
return `${getStoragePrefix()}${TOKEN_SUFFIX}`;
|
|
12
|
+
};
|
|
13
|
+
export const getTokenChangedEventName = () => {
|
|
14
|
+
return `${getStoragePrefix()}${TOKEN_CHANGED_SUFFIX}`;
|
|
15
|
+
};
|
|
16
|
+
export const getToken = () => {
|
|
17
|
+
if (typeof window === 'undefined')
|
|
18
|
+
return null;
|
|
19
|
+
return localStorage.getItem(getTokenStorageKey());
|
|
20
|
+
};
|
|
21
|
+
export const setToken = (token) => {
|
|
22
|
+
if (typeof window === 'undefined')
|
|
23
|
+
return;
|
|
24
|
+
localStorage.setItem(getTokenStorageKey(), token);
|
|
25
|
+
};
|
|
26
|
+
export const removeToken = () => {
|
|
27
|
+
if (typeof window === 'undefined')
|
|
28
|
+
return;
|
|
29
|
+
localStorage.removeItem(getTokenStorageKey());
|
|
30
|
+
};
|
|
31
|
+
export const dispatchTokenChanged = () => {
|
|
32
|
+
if (typeof window === 'undefined')
|
|
33
|
+
return;
|
|
34
|
+
window.dispatchEvent(new Event(getTokenChangedEventName()));
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../middleware.ts"],"names":[],"mappings":";AAEA,wBAA6B;AAE7B,eAAO,MAAM,MAAM;;CAElB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-bootstrap.d.ts","sourceRoot":"","sources":["../server-bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GET, revalidate } from './core/server/raxon.bootstrap.route';
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { raxonServer } from './core/server/raxon.server';
|