feat(global) containerize

This commit is contained in:
lumither committed 2024-08-01 01:39:24 +08:00
1 parent 36f686c563
commit fbc9736831
20 files changed
+180 -91

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
const LOCAL_ENDPOINT = process.env.API_LOCAL_URL;
const REMOTE_ENDPOINT = process.env.API_REMOTE_URL;
const NOCTURNE_ENDPOINT = ((isServerSide = true) => {
if (process.env.NODE_ENV === 'production') {
if (isServerSide) {
return LOCAL_ENDPOINT;
} else {
return REMOTE_ENDPOINT;
}
} else {
return LOCAL_ENDPOINT;
}
});
export async function fetchNocturneApi(path: string, isServerSideRequest = true): Promise<{ code: number, ret: any }> {
let res = await fetch(`${ NOCTURNE_ENDPOINT(isServerSideRequest) }${ path }`, {
cache: 'no-cache'
});
if (!res.ok) {
return { code: res.status, ret: (await res.json()) };
}
return { code: res.status, ret: await res.json() };
}