Firebase and backend logic

后端 未结 3 824
梦如初夏
梦如初夏 2020-11-30 02:16

I am parse.com user, and now I look for another service. How can I write back end logic to firebase?

let say I want to validate all the values on server side, or t

3条回答
  •  余生分开走
    2020-11-30 02:53

    Here's what I would do:

    • Validade all the inputs with the ".validate" rules. No server needed for that.
    • If you have tasks to run, use Firebase Queue, a bot to run the tasks and you are done.

    If you don't do the last one, you may have two problems:

    • If you try use the diagram you posted it will be a little tricky to get the auth object at the server (but not impossible). Go ahead if you don't need to validate the user to allow the request.

    • If you use just the regular firebase app to listen to changes and respond (editing the object for instance, like Frank van Puffelen's example code), you might have scalability problems. Once your back end scales to two (or more) instances, a firebase edit will trigger the task on all of them. Each instance will notice there was a change, then run the same task once each, add/replace the response object once each and try to remove the request object once each..

    Using Firebase Queue avoids both of these problems.

提交回复
热议问题