This Plugin adapts parse-server to support streams with some extra benefits:
-
True Upsert: Inserting directly to mongo via a bulkUpdate allows to handle millions of rows (parse-server slows downs insertions as the rows increase)
-
BigNumber Support: Allows bigNumbers to be inserted into MongoDB via numberDecimal.
-
This plugin only works with MongoDB
-
Parse-Dashboard will not work due to numberDecimal, we will be releasing our version of dashboard with numberDecimal support soon.
First clone the parse server repo and install the dependencies.
This plugin was tested with v5.2.7 of parse server
git clone -b release https://github.com/parse-community/parse-server.git
Install the Plugin in your parse-server:
npm install parse-server-moralis-streams
The Plugin needs to run some patches before the server starts.
To do so, run the prepare
script of the plugin.
npx parse-server-moralis-streams prepare
Create a folder in your project root called cloud
and add a file called streams.json
with the following content:
Example:
[
{
"tableName": "MyStream",
"tag": "myStream"
}
// ...
]
The Streams object defines the streams that will be used by the plugin. It is an array of objects with the following properties.:
- tableName (string): The name of the table that will be used to store the stream data in MongoDB
- tag (string): The tag that will be used to identify the stream
You should have a config file in your root folder.
Usually its called config.json
add the following to the config file:
{
//..
"moralisApiKey": "YOUR_MORALIS_WEB3_API_KEY",
"streamsConfig": "./cloud/streams.json",
}
Now you can run the server with following command:
npm start ./config.json
Specifying the path to your config file is required.
The endpoint to receive webhooks is YOUR_SERVER_URL:PORT/streams
. This is the URL that you should use when setting up a stream.
After you have configured the plugin and created a stream you can see the data in the dashboard. Note that the tableName will be concatenated with Txs
and Logs
meaning if you have a tableName called "MyTable" you will have two collections in mongoDB called "MyTableTxs" and "MyTableLogs", you will also have ERC20Transfers/Approvals and NFTTransfers/Approvals collections by default.