{"id":20863344,"url":"https://github.com/howardabrams/mongrue","last_synced_at":"2025-03-12T14:43:30.202Z","repository":{"id":66137096,"uuid":"2264661","full_name":"howardabrams/mongrue","owner":"howardabrams","description":"A simple, free-form REST interface to a MongoDB database instance built on top of node.js.","archived":false,"fork":false,"pushed_at":"2011-12-19T22:51:54.000Z","size":136,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-19T08:15:26.820Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/howardabrams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-08-24T22:23:58.000Z","updated_at":"2013-11-04T09:10:17.000Z","dependencies_parsed_at":"2023-02-19T23:15:39.228Z","dependency_job_id":null,"html_url":"https://github.com/howardabrams/mongrue","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fmongrue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fmongrue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fmongrue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fmongrue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/howardabrams","download_url":"https://codeload.github.com/howardabrams/mongrue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243236516,"owners_count":20258849,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T05:28:37.026Z","updated_at":"2025-03-12T14:43:30.181Z","avatar_url":"https://github.com/howardabrams.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mongrue:\nA simple, free-form REST interface to a MongoDB database instance.\n\n\u003e It is pitch black. You are likely to be eaten by a *mongrue*.\n\nThis is not the kind of service you would want to use in a production\nenvironment. It has not security, no limits and virtually no structure.\nThat is the point.\n\nThink of this project as a perfect server-mock that would allow you to\ninitially build your JavaScript client. With a little modification,\nyou can put some limits and a little security to it to allow your\nJavaScript client to use this for server-side storage without needing\nany HTML5 capabilities.\n\nGet it Going\n============\n\nThis project depends on a local [node.js][1] installation as well as a\n[MongoDB][2] running on the localhost. So before you begin, get both\nof those installed and running... then come back.\n\nDon't worry. I'll wait.\n\nInstallation\n------------\n\nAlright, now that both of those guys are installed, you need to \ninstall [NPM][3], using the following\ncommand:\n\n    $ curl http://npmjs.org/install.sh | sh\n\nWhat? You already have that installed? Smart kid. Here's a nickel.\n\nUse the *NPM* to install the following dependency:\n\n    $ npm install mongodb\n\nYes, you probably guessed that was the only dependency. Here's\nanother nickel.\n\n\nRunning the Server\n------------------\n\nAssuming you have [MongoDB][2] running on the local host, all you need\nto do to get the server going, is:\n\n    $ node index.js\n\nBut before you run it, you might want to edit the `config.js` file:\n\n    $ vi config.js\n\nThis file contains the configuration values. Note the two most important\nones that I tacked on to the end of that file:\n\n  * `clientKey`: If this is set (and I suggest you uncomment it), every\n    client request must include a `x-mongrue-clientkey` HTTP header with\n    a value that corresponds to that key. Just a wee bit of a safety check.\n\n  * `collectionNames`: This contains a list of the acceptable *collections*\n    (that is MongoDB parlance for the REST concept of *resources*). For\n    instance, `http://localhost:8888/unicorns` will work if this contains a\n    `unicorns` property that is set to `1`.\n\nREMEMBER: This project is really a *template project*. It is intended that\nyou'll want to modify it... *significantly*. This is just a kick starter for\nyour own creation.\n\nThe code structure came from the [Node Beginner][4] website, so you may\nwant to read that article before diving into the source.\n\n\nProject Tests\n-------------\n\nSince JavaScript has this interesting little feature called *cross-site domain calls*,\nit makes it pretty difficult to run QUnit tests in a browser when they test the\nresults of our Mongrue project.\n\nSo, if you request [http://localhost:8888/test/](http://localhost:8888/test/), you\nwill start up the unit tests, which will call back to the server and perform \nthe unit tests in the `test.js` file. (Oh yeah, that final slash is important).\n\n\nUsing the Beast\n===============\n\nLike I said before, this is a simple REST interface to the MongoDB\ndatabase. The following are the only commands it accepts:\n\nGET ALL\n-------\n\nLet's supposed you had a *collection* of `users` in your Mongo, you can retrieve them all by:\n\n    GET http://localhost:8888/users\n\nTold you it was simple. You can give it the standard Mongo range parameters, like:\n\n    GET http://localhost:8888/users?limit=2\n    GET http://localhost:8888/users?skip=10\n    GET http://localhost:8888/users?sort=name\n\nWhy yes, you can combine them in meaningful ways:\n\n    GET http://localhost:8888/users?limit=2\u0026skip=10\u0026sort=name\n\nI would really like to be able to pass [advanced queries][5] with\na `query` parameter, like:\n\n    GET http://localhost:8888/users?query={\"username\":\"howard\"}\n\nNote to self: This *kinda* works, but I would really like to figure out how to\ndo the range of `$gt` and other Mongo operations.\n\nGET ID\n------\n\nOnce you have the `_id` of the entry, you can specify this on the GET\nline to retrieve just that one entry, as in:\n\n    GET http://localhost:8888/users/4e5550c3718adf0000000001\n\nWhich in my database, returns:\n\n    {\n      \"username\": \"howard\",\n      \"title\": \"Code Carpenter\",\n      \"_id\": \"4e5550c3718adf0000000001\"\n    }\n\nNote: If you have a *model id* with a parameter of `id`, you can use that instead of the Mongo `_id` value. For instance:\n\n    GET http://localhost:8888/users/42\n\nWhich *could* return:\n\n    {\n      \"id\" : 42\n      \"username\": \"howard\",\n      \"title\": \"Code Carpenter\",\n      \"_id\": \"4e5550c3718adf0000000001\"\n    }\n\nHow does it tell which is which? Length, baby. If it is 12 bytes long, then its a foot, and therefore, we search the `_id` field, otherwise, we look for a `id` field. That's right, size matters.\n\nPOST\n----\n\nHow do you get new entries in the database? Using `POST` of course. The *body* of the `POST` must be a JSON-formatted object, which will be shoved into the *collection* specified in the URL. For instance:\n\n    POST http://localhost:8888/users\n\nWhere the *body* is:\n\n    { \"username\":\"bobdog\", \"title\":\"King Fool\" } \n\nWill return what was put into the database:\n\n    {\n      \"username\": \"bobdog\",\n      \"title\": \"King Fool\",\n      \"_id\": \"4e5578ce3e89ba0000000001\"\n    }\n\nObviously, that `_id` value may prove to be important, later.\n\nPUT\n---\n\nAllows you to *replace* the contents of an existing entry. Let's\nsuppose we did the `POST` example above, and got the `_id` value\nshown, we could:\n\n    PUT http://localhost:8888/users/4e5578ce3e89ba0000000001\n\nWith a body:\n\n    { \"username\":\"bobdog\", \"title\":\"King for a Day\" } \n\nNote: This returns the entry that was replaced, not the entry as it is *currently*.\nYeah, I suppose neither response is that helpful.\n\nDELETE\n------\n\nRemove an entry using the `DELETE` method, as in:\n\n    DELETE http://localhost:8888/users/4e5578ce3e89ba0000000001\n\nWhich simply returns the words `OK`.\n\n\nWhat's Next\n===========\n\nI've warned you time and time again to wipe your nose, and modify this code before\ndoing anything else. This project really is a *template* for you to use to do something\nwith. Don't expect that you can just modify the `config.js` file and it will give you\nwhat you need.\n\nHowever, this brings me to the top tasks that I'd like to add to this project so that\nit is more useful out of the box.\n\nTasks\n-----\n\n  * Add a `config.js` file that can be use to specify application properties. @done\n  * Add a private `application id` string that needs to be passed in to verify\n    the client. @done\n  * Add an array somewhere of the *collections* that can be accessed. @done\n  * Add a notion of a *user account* that may or may not correspond to a Mongo\n    database.\n\nI'm sure we'll make this list longer if we think about it.\n\n  [1]: http://www.nodejs.org\n  [2]: http://www.mongodb.org\n  [3]: http://howtonode.org/introduction-to-npm\n  [4]: http://www.nodebeginner.org\n  [5]: http://www.mongodb.org/display/DOCS/Advanced+Queries","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowardabrams%2Fmongrue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhowardabrams%2Fmongrue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowardabrams%2Fmongrue/lists"}