0.0.3 • Published 5 years ago

firebase-rule-generator v0.0.3

Weekly downloads
-
License
GPL-3.0
Repository
gitlab
Last release
5 years ago

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();
    }
  }
}
0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago