@@ -0,0 +1,40 @@
|
||||
import { fetch } from "pouchdb-fetch";
|
||||
|
||||
const dbsSecurity = {
|
||||
web_push_subscriptions: {
|
||||
admins: { roles: ["_admin"] },
|
||||
members: { roles: [] },
|
||||
},
|
||||
messages: {
|
||||
admins: { roles: ["_admin"] },
|
||||
members: { roles: [] },
|
||||
},
|
||||
server_settings: {
|
||||
admins: { roles: ["_admin"] },
|
||||
members: { roles: ["_admin"] },
|
||||
},
|
||||
// qr: {
|
||||
// admins: { roles: ["_admin"] },
|
||||
// members: { roles: [] },
|
||||
// },
|
||||
};
|
||||
|
||||
export const up = async () => {
|
||||
for (const [dbName, dbSecurity] of Object.entries(dbsSecurity)) {
|
||||
await fetch(`${process.env.API_URL}/${dbName}`, {
|
||||
method: "PUT",
|
||||
});
|
||||
await fetch(`${process.env.API_URL}/${dbName}/_security`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(dbSecurity),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const down = async () => {
|
||||
for (const dbName of Object.keys(dbsSecurity)) {
|
||||
await fetch(`${process.env.API_URL}/${dbName}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user