Add pocketbase util
This commit is contained in:
7
web/package-lock.json
generated
7
web/package-lock.json
generated
@@ -11,6 +11,7 @@
|
||||
"@astrojs/node": "^9.5.0",
|
||||
"@tailwindcss/vite": "^4.1.17",
|
||||
"astro": "^5.15.4",
|
||||
"pocketbase": "^0.26.3",
|
||||
"tailwindcss": "^4.1.17"
|
||||
}
|
||||
},
|
||||
@@ -4398,6 +4399,12 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/pocketbase": {
|
||||
"version": "0.26.3",
|
||||
"resolved": "https://registry.npmjs.org/pocketbase/-/pocketbase-0.26.3.tgz",
|
||||
"integrity": "sha512-5deUKRoEczpxxuHzwr6/DHVmgbggxylEVig8CKN+MjvtYxPUqX/C6puU0yaR2yhTi8zrh7J9s7Ty+qBGwVzWOQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.6",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"@astrojs/node": "^9.5.0",
|
||||
"@tailwindcss/vite": "^4.1.17",
|
||||
"astro": "^5.15.4",
|
||||
"pocketbase": "^0.26.3",
|
||||
"tailwindcss": "^4.1.17"
|
||||
}
|
||||
}
|
||||
|
||||
13
web/src/utils/pocketbase.ts
Normal file
13
web/src/utils/pocketbase.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import PocketBase from "pocketbase";
|
||||
|
||||
const pb = new PocketBase("/");
|
||||
|
||||
export const authPB = async () => {
|
||||
if (!pb.authStore.isValid) {
|
||||
await pb.collection('users').authWithPassword(
|
||||
import.meta.env.PB_EMAIL,
|
||||
import.meta.env.PB_PW
|
||||
);
|
||||
}
|
||||
return pb;
|
||||
};
|
||||
Reference in New Issue
Block a user