Cher
Quick Start
Prep your environment
$ echo "APP_NAME=appName" >> .env
$ echo "DATABASE_URL=postgres://user:password@hostname:port/database" >> .env
$ echo "REDIS_URL=redis://hostname:port/" >> .env
$ echo "ADMIN_USER=foo" >> .env
$ echo "ADMIN_PASS=pa$$word" >> .env
$ echo "NODE_ENV=local" >> .env
$ echo "CALLBACK_URL=http://localhost:3000" >> .env
$ echo "SECRET=secretkey" >> .env
Ensure your database and user is created
createdb dbname
createuser dbuser
Start it up
foreman start
Meanwhile, in your code
const Cher = ; const cherTwitter = ; const cherInstagram = ; const tools = ; // filter dirty words const dirtyFilter = toolspipelineprofanityFilter; // save data to the database const save = toolspipelinesave; // config helper const config = toolsutilsconfig; // Cher streams get configured here. const sourceStreams = name: 'twitter' module: cherTwitter name: 'instagram' module: cherInstagram ; config ;
Pipelines
Cher is a stream processing platform. The best way to process a stream of data is through a data pipeline. Cher provides several pipeline steps out of the box for you to utilize including a save()
which simply saves data to the database. In order to create a step in the pipeline just create a function which returns a through stream. The function which returns the through stream will receive one parameter deps
which is an object that provides several components that you can utilize in your pipeline step.
{
models,
ctx,
settings
}
models
An instance of the cher model manager which gives you access to your underlyning data model. You can access it like so
const DataModel = models;
ctx
An instance of a key/value store that cher has access to which you can use to store arbitrary data.
ctx // don't forget to catch errors!
settings
The configured settings for the current sourceStream. If the data item coming through the pipeline is from twitter, this will be the twitter settings. If it is from S3, it will be the S3 settings.
Putting it all together
So, what does a custom pipeline step look like? Simple
const es = ;const tools = ; module { return es;};