``update Extract PocketBase URL to constant and refactor related functions to use it for dynamic file URL generation
``
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
//
|
||||||
|
// PURPOSE:
|
||||||
|
// get file url from pocketbase record
|
||||||
|
//
|
||||||
|
|
||||||
|
import { POCKETBASE_URL } from '../constants';
|
||||||
|
|
||||||
|
export default function getImageUrlFromFile(collectionId: string, id: string, imgFile: string | undefined): string {
|
||||||
|
return `${POCKETBASE_URL}/api/files/${collectionId}/${id}/${imgFile}`;
|
||||||
|
}
|
@@ -1,5 +1,7 @@
|
|||||||
|
import { POCKETBASE_URL } from '../constants';
|
||||||
import { DBUserMeta } from '../db/UserMetas/type';
|
import { DBUserMeta } from '../db/UserMetas/type';
|
||||||
|
|
||||||
export function getStudentAvatar(studentMeta: DBUserMeta) {
|
export function getStudentAvatarUrl(studentMeta: DBUserMeta) {
|
||||||
return `url(http://localhost:8090/api/files/${studentMeta.collectionId}/${studentMeta.id}/${studentMeta.avatar})`;
|
const { collectionId, id, avatar } = studentMeta;
|
||||||
|
return `url(${POCKETBASE_URL}/api/files/${collectionId}/${id}/${avatar})`;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
import PocketBase from 'pocketbase';
|
import PocketBase from 'pocketbase';
|
||||||
|
import { ERR_POCKETBASE_URL_IS_EMPTY } from '../ERRORS';
|
||||||
|
import { POCKETBASE_URL } from '../constants';
|
||||||
|
|
||||||
const pb = new PocketBase('http://127.0.0.1:8090');
|
const pb = new PocketBase(POCKETBASE_URL);
|
||||||
|
|
||||||
export { pb };
|
export { pb };
|
||||||
|
Reference in New Issue
Block a user