firebase-rule-generator
v0.0.3
Published
A node app which converts JSON BD schemas into Firebase Firestore Rules
Downloads
8
Maintainers
Readme
firebase-rule-generator (WIP)
An app which converts JSON DB schemas into Firebase Firestore Rules.
Sample Input:
{
"users": {
"_frug_": {
"read": "TBD"
},
"uid": {
"uid": "uid",
"given_name": "string",
"favorite_color": "/^(yo)?u\s+can\s+RegEx$/"
}
}
}
Sample Output:
service cloud.firestore {
match /databases/{database}/documents {
function inData() {
return request.resource.data;
}
function inAuth() {
return request.auth
}
function isUser() {
return inData().uid == inAuth().uid &&
inData().given_name is string &&
inData().favorite_color.matches('^(yo)?u\s+can\s+RegEx$');
}
match /users/{uid} {
allow write: if isUser();
}
}
}