- MongoDB
- Run this with
mongod
- Run this with
- ElasticSearch
- Run this with
elasticsearch -f
- Run this with
Execute npm install
in the application directory:
Copy and edit your .env file. -- This should never be committed to the repo. Ensure that you fill in the ALLOWED_USERS variable.
cp .env.sample .env
Before you start your Node.js server, you'll need to run MongoDB and ElasticSearch
Assuming MongoDB and ElasticSearch are running at the specified places in your .env
file simply running node server.js
from the root should start the server.
By default the server will run at http://localhost:5000. You can change this by adding PORT= to your .env file.
To enable New Relic, set the NEW_RELIC_ENABLED
environment variable and add a config file, or set the relevant environment variables.
For more information on configuring New Relic, see: https://github.com/newrelic/node-newrelic/#configuring-the-agent
If you don't have Heroku Toolbelt get it here https://toolbelt.heroku.com/.
You will need an account with heroku. If you don't have one, sign up for one at http://heroku.com.
- Ensure you are logged in first by running
heroku login
- Go to the root of the repo.
heroku create
- Add the necessary plugins using
heroku addons:add <plugin name>
. Supported MongoDB plugins are: MongoHQ and MongoLab. Supported Elastic Search plugins are: FoundElasticSearch and Bonsai. Installing a plugin should automatically set up the required environment variables. - You should be ready to push up to heroku!
git push heroku featureBranchName:master
. If all goes well, your app should deploy. You can see logs by runningheroku logs
and you can open the MakeAPI in a browser by runningheroku open
.
Right now there is a small node app in test/test-make-client.js
that will require in the API and make a sample create request. This is reliant upon the the entire repo being included down and not being pulled in through NPM. Eventually there will be tests not reliant on this.
HTTP Method | Path | Action | Notes | Auth Required |
---|---|---|---|---|
POST | /api/make | Create Make | If Post Data is a valid Make, it creates one and returns it with the _id and __v populated. | Yes |
PUT | /api/make/:id | Update a Make | The Make must already exist and the __v must be the same as the current version on the server. This is an implementation of optimistic locking. | Yes |
DELETE | /api/make/:id | Deletes a Make | The effect is that of a delete operation, though the Make is actually only marked as deleted using the deletedAt timestamp. | Yes |
GET | /api/makes/search | Find makes by search criteria | Searches for makes using elasticsearch. The Query String of your request must be stringified and escaped JSON, and must use elastic search's Query DSL. e.g. |
No |
jQuery.ajax({
type: "POST",
url: "/api/make",
data: {
"url": "http://thimble.webmadecontent.org/abcd.html",
"contentType": "text/html",
"title": "Animal something-or-other",
"locale": "en_us",
"tags": ["awesome"],
"privateTags": ["webmaker.org:project", "skill:css"],
"description": "This handy HTML template makes it easy to quickly create your own text and image mashup, then publish it for sharing via Facebook, Tumblr or any web page. Your 15 seconds of internet fame await!",
"author": "swex@mozilla.com",
"contentAuthor": "swex@mozilla.com",
"remixedFrom": null,
"published": true
},
success: function(data, textStatus, jqXHR){
console.log("Post resposne:");
console.dir(data);
console.log(textStatus);
console.dir(jqXHR);
},
error: function(jqXHR, textStatus, errorThrown){
console.log(jqXHR.responseText);
}
});
If you load http://localhost:5000/search.html, you can use the basic set of form fields to create/update/delete makes and search based on several fields.'
Running AUTH=<username>:<password node test/post.js
from the root of the repository will generate one thousand fake records in your database. Be sure to include a valid username and password as an environment variable.
Clear elastic search:
curl -XDELETE "http://localhost:9200"
Find your mongo files and clear them. For example, if your makeapi.1
, etc. are in /data/db/
, run:
rm /data/db/makeapi.*