What is Firebase?
Firebase is a real-time back-end database startup company that can help developers quickly write web and mobile applications. In October 2014, Google acquired Firebase and later integrated Firebase into Google’s cloud services.
Does Firebase Work in China?
According to Google Beijing, No it can not be used in China.
According to Chinese laws, data of Chinese users must be stored on servers within China. Therefore, it is not allowed to store user data in databases outside of China. Also, using agents or other methods of data storage is not a long-term solution.
Firebase's Open Source Alternative is Parse
What is Parse?
Parse is a cloud-based back-end management platform. For developers, Parse provides back-end one-stop and package services: server configuration, database management, API, video and audio file storage, real-time message push, customer data analysis and statistics, etc. In this way, developers only need to handle the development of the front-end/client/mobile-end, and hand over the back-end to Parse.
Facebook acquired Parse in 2013, and later decided to close Parse, and finally Parse decided to open source their code, and now Parse Server/parse-server) and Parse Dashboard, and recently GraphQL Other functions.
21YunBox provides a Parse Server alternative to Firebase within China. We provide an operations and maintenance free one-click hosting solution.
How to Create a Parse Server?
- Register as 21YunBox member
- Create a MongoDB database
- Fork Parse Server startup template
- Create a cloud service on 21YunBox and allow 21YunBox to access your code base
- Create with the following configuration
Environment. | Node |
---|---|
Build command | yarn install |
Start command | yarn start |
Click Advanced Configuration to configure environment variables:
KEY | VALUE |
---|---|
APP_ID | Randomly generate 32-bit characters |
MASTER_KEY | Randomly generate 32-bit characters |
MONGODB_URI | Click Database URL in the cloud database console to obtain |
SERVER_URL |
<APP_ID>.21cloudbox.com , such as parse-server-demo.21cloudbox.com
|
PORT |
10000 , default port used by 21CloudBox |
For more other Parse Server environment variable configurations, please refer to Official Document.
Randomly generate 32-bit characters method:
Paste the following command on the command line:
echo $(base64 /dev/urandom | head -c32)
After Parse is successfully deployed, you can go to <APP_ID>.21cloudbox.com/test
for testing. When the test is successful, you will see the following:
Step-by-Step Setup and Deploy Video:
[View video demo]:(https://www.bilibili.com/video/BV1Rh411S7um) Firebase Alternative-how to deploy Parse to the server.
How to use Parse Server to Create and Read Data?
You can use the curl
command or the visual interface Postman to help you create and read data.
Create Data
Created in curl
way
curl -X POST \
-H "X-Parse-Application-Id: <APPLICATION_ID>" \
-H "Content-Type: application/json" \
-d'{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
https://<APP_ID>.21cloudbox.com/parse/classes/GameScore
After the successful creation, you should receive a similar json
{
"objectId": "9ed7LlOzn2",
"createdAt": "2021-03-25T07:03:28.668Z"
}
Read Data
** Via objectId
, read the data created above**
curl -X GET \
-H "X-Parse-Application-Id: APPLICATION_ID" \
https://<APP_ID>.21cloudbox.com/parse/classes/GameScore/9ed7LlOzn2
// Response
{
"objectId": "9ed7LlOzn2",
"score": 1337,
"playerName": "Sean Plott",
"cheatMode": false,
"createdAt": "2021-03-25T07:03:28.668Z",
"updatedAt": "2021-03-25T07:03:28.668Z"
}
Create and read data demos with Postman:
View a demo video of Firebase domestic alternative-create and read data with Postman
In addition to the simple method of using curl or Postman to create data above, Parse also provides a multi-language SDK (iOS, Android, PHP, etc.). For more details, please refer to the official Parse technical documentation: http://docs.parseplatform. org/
Related Articles
-How to deploy Parse Dashboard to the server?
For additional detail and future modifications, refer the original post.
Top comments (0)