Authors - The Washington Post
The Submission Platform is a dynamic form builder that lets you collect and manage user submissions of text, images, and other data. It is built entirely on the MEAN (MongoDB, Express, Angular, Node.js) stack.
##Component Versions
MongoDB - v 3.2
ExpressJS - v 4.12.4
AngularJS - v 1.4.7
NodeJS - v 10.25
STEP 1
Install node: https://nodejs.org/download/ (You can also install NodeJS using homebrew or any package manager.)
Install bower: http://bower.io/#install-bower
Install grunt: http://gruntjs.com/getting-started
STEP 2
IMPORTANT: You can choose either the hosted or local methods for Mongo and Elasticsearch. You can mix and match if you prefer.
Option A: Hosted Services
There are several config files located in the config directory. They contain connection strings to hosted instances of ElasticSearch and MongoDB.
These can be used for testing, but the data is publicly available, so do not create users with sensitive passwords, etc.
Mongo Config - config/db_local.js
ElasticSearch Config - config/elastic.js
Check both config files to make sure you have commented out the local connection string and use the hosted connection string.
The app also uses a hosted media service for uploaders. Currently we aren't providing a hosted or local variation of this, but will be asap.
Option B: Local Services
-
Install mongodb: https://www.mongodb.org/downloads#production
1.1 Start the Mongo service
1.2 Create a database named subuse sub
1.3 Add user sub_test to the sub database. Make sure the user has readWrite role on the DB and the PW matches the one in the connection string in config/db_local.js (example below in help section)
1.4 Optionally you can import this data dump to your database: https://s3.amazonaws.com/wpentdev/coral/mongodump.zip
1.4.1 Import command will be:mongorestore --host 127.0.0.1 --port 27017 --db sub /location/of/download/dump/sub
1.5 Check config/db_local.js to make sure you have commented out the hosted connection string and use the local connection string.
-
Set up a local Elastic search instance.
Follow the instructions here:
https://www.elastic.co/guide/en/elasticsearch/guide/current/running-elasticsearch.html
2.1 Check config/elastic.js to make sure you have commented out the hosted connection string and use the local connection string.
STEP 3
Open up Terminal or Command Prompt. Navigate to your project folder via command line (Ex: cd /Desktop/Sub-Coral) and run the following commands in order.
$ npm install
$ bower install
$ grunt
Now all of your dependencies, assets and services are installed and configured. Run the command
$ node server.jsYou will see a series of messages, starting with this "Action=DBConnect Message='Connected to QA MongoDB'" That means you have successfully started your app and connected to your DB.
In your browser visit http://localhost:3000 the app will load up there.
This is a guide to MongoDB shell commands.
Create a database: Once you have installed your MongoDB server and entered into the shell, you can create a new database with the following:
Example:
use subThis will create the database and save it as long as you add a document to it.
Create a collection: When in a database, to create a collection, you need to add a document by pointing to the desired name of the new collection and the collection will be created.
Example:
db.myCollection.insert ({value: "my first document"})
Create a user: You can create a user for any database when in the mongo shell. There are many different rolse and settings that can be created, but here is the basic way to create a user for a specific database.
Example:
use sub db.createUser( { user: "sub_test", pwd: "mysecretpassword", roles: [ "readWrite", "sub" ] } )
This is a guide to ElasticSearch queries.
You can access elasticsearch at the endpoint in the config file and add :9200 at the end of the url in your browser.
Marvel Sense
There is a plugin called Marvel Sense installed that allows you to run queries in your browser against your cluster.
The plugin can be viewed here: http://coralsearch.wpentdev.com:9200/_plugin/marvel/sense/
Queries to run are:
GET /_cluster/health
(gets cluster health)
GET /_cluster/stats
(gets cluster stats)
GET /_nodes/stats
(gets node stats)
GET /_cat/indices?v
(gets index stats)
Big Desk
There is a plugin called Big Desk installed that allows you to visualize your cluster.
The plugin can be seen here: http://coralsearch.wpentdev.com:9200/_plugin/bigdesk/#cluster