Add pocketbase util

This commit is contained in:
2025-11-14 09:57:07 +13:00
parent bd746f4e75
commit e930e75646
7 changed files with 117 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("jbzxvie5c27b6od")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"updateRule": "",
"viewRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("jbzxvie5c27b6od")
// update collection data
unmarshal({
"createRule": null,
"deleteRule": null,
"updateRule": null,
"viewRule": null
}, collection)
return app.save(collection)
})

View File

@@ -0,0 +1,28 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("jbzxvie5c27b6od")
// update collection data
unmarshal({
"createRule": null,
"deleteRule": null,
"listRule": null,
"updateRule": null,
"viewRule": null
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("jbzxvie5c27b6od")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"listRule": "",
"updateRule": "",
"viewRule": ""
}, collection)
return app.save(collection)
})

View File

@@ -0,0 +1,20 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("my9ej2vdwzwoqov")
// update collection data
unmarshal({
"listRule": "@request.auth.email=\"site@breadone.net\""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("my9ej2vdwzwoqov")
// update collection data
unmarshal({
"listRule": ""
}, collection)
return app.save(collection)
})

View File

@@ -0,0 +1,22 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("jbzxvie5c27b6od")
// update collection data
unmarshal({
"listRule": "@request.auth.email=\"site@breadone.net\"",
"viewRule": "@request.auth.email=\"site@breadone.net\""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("jbzxvie5c27b6od")
// update collection data
unmarshal({
"listRule": null,
"viewRule": null
}, collection)
return app.save(collection)
})

7
web/package-lock.json generated
View File

@@ -11,6 +11,7 @@
"@astrojs/node": "^9.5.0", "@astrojs/node": "^9.5.0",
"@tailwindcss/vite": "^4.1.17", "@tailwindcss/vite": "^4.1.17",
"astro": "^5.15.4", "astro": "^5.15.4",
"pocketbase": "^0.26.3",
"tailwindcss": "^4.1.17" "tailwindcss": "^4.1.17"
} }
}, },
@@ -4398,6 +4399,12 @@
"url": "https://github.com/sponsors/jonschlinkert" "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": { "node_modules/postcss": {
"version": "8.5.6", "version": "8.5.6",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",

View File

@@ -12,6 +12,7 @@
"@astrojs/node": "^9.5.0", "@astrojs/node": "^9.5.0",
"@tailwindcss/vite": "^4.1.17", "@tailwindcss/vite": "^4.1.17",
"astro": "^5.15.4", "astro": "^5.15.4",
"pocketbase": "^0.26.3",
"tailwindcss": "^4.1.17" "tailwindcss": "^4.1.17"
} }
} }

View 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;
};