{"id":15388929,"url":"https://github.com/killercodemonkey/nodejs-restapi","last_synced_at":"2025-10-27T05:14:32.397Z","repository":{"id":19989997,"uuid":"23257236","full_name":"KillerCodeMonkey/NodeJS-RestAPI","owner":"KillerCodeMonkey","description":"RestAPI with NodeJS, MongoDB, Token authentication and Multi Database support, Mocha tests, Endpoint Documentation","archived":false,"fork":false,"pushed_at":"2014-08-23T14:11:22.000Z","size":172,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-18T23:13:03.043Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KillerCodeMonkey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-23T14:06:09.000Z","updated_at":"2022-10-31T02:45:42.000Z","dependencies_parsed_at":"2022-08-31T06:01:39.477Z","dependency_job_id":null,"html_url":"https://github.com/KillerCodeMonkey/NodeJS-RestAPI","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/KillerCodeMonkey%2FNodeJS-RestAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KillerCodeMonkey%2FNodeJS-RestAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KillerCodeMonkey%2FNodeJS-RestAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KillerCodeMonkey%2FNodeJS-RestAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KillerCodeMonkey","download_url":"https://codeload.github.com/KillerCodeMonkey/NodeJS-RestAPI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241175431,"owners_count":19922508,"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-10-01T14:58:38.493Z","updated_at":"2025-10-27T05:14:27.361Z","avatar_url":"https://github.com/KillerCodeMonkey.png","language":"JavaScript","readme":"RestAPI [![Build Status](https://travis-ci.org/KillerCodeMonkey/restAPI.svg?branch=master)](https://travis-ci.org/KillerCodeMonkey/NodeJS-RestAPI)\n================\nNodeJS/MongoDB REST-API with token authentication and multidb support\n\nThis is an example how to create a flexible rest api with nodejs + mongodb, permission handling, multidb support (+ caching connections), documented endpoints, test cases and using test/build-runners like travis-ci\n\nInstallation\n============\nRequirements\n------------\n1. install nodejs\n  * `sudo apt-get update`\n  * `sudo apt-get install -y gcc g++ make`\n  * `wget http://nodejs.org/dist/node-latest.tar.gz`\n  * `tar -xzvf node-latest.tar.gz`\n  * `cd [CREATED NODE DIR]`\n  * `./configure`\n  * `make`\n  * `sudo make install`\n  * `curl https://www.npmjs.org/install.sh | sh`\n  * if curl is missing run `apt-get install curl`\n2. install mongodb (check if version \u003e2.6.x)\n  * open http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/\n  * Follow the installation instructions (Point 1 - 4)\n3. clone repo \u0026 go in directory\n4. run `npm install` to install all dependencies\n5. run `npm install -g grunt-cli`\n6. set configs in ./config and run following commands (optional)\n\nAPI - New Way\n-------------\n1. run `grunt exec:install`\n\nAfter you have configured your mongo and installed the system the first time you only need grunt reinstall to install demodata and grunt to start server (hopefully).\nYour system admin credentials:\n* login: test\n* pw: 1234\n\nStart\n=====\n* after reboot of your VM/System run\n  * `grunt exec:killDB`\n  * `grunt exec:startDB`\n  * `grunt`\n\nDocumentation\n=============\n* current documentation open: docs/index.html\n* generate documentation with `grunt exec:doc`\n\nTests\n=====\n* run `grunt tests`\n* there should be a testcase for each endpoint (success and failure cases)\n\nExplanation\n===========\n* index.js -\u003e init server and workers (clustering)\n* appServer.js -\u003e express server, request handling, middleware for authentication\n* config -\u003e db, app, require, logging configs\n* endpoints -\u003e rest endpoints\n* models -\u003e db models (schema and model)\n* middleware -\u003e custom express middleware for authentication and multidb handling, store selection\n* util -\u003e handler and other tools\n* tests -\u003e testcases\n\nModels \u0026 Endpoints\n=================\n* model and endpoint file (if there are endpoints for a model -\u003e model and endpoint must have the same name)\n* on startup all models are loaded and for all models the entpoint file\n* model registers the mongoose model with its schema\n* Versioning\n* MultiDB support: '/api/:version/:database/:classname/id/:id/:action' -\u003e for each client an own db\n* endpoint file returns an object with keys for each method (post, get, put, delete) as values another object with keys '', 'object', '{actionname}'. '' stands for request without objectid like '/api/user'. 'object' for a object call like '/api/v1/restAPI/user/:id' where the object is placed automatically on req.object. '{actionname}' could be used if the default methods are not enough for any purpose like GET '/api/v1/restAPI/user/id/:id/rating' or GET '/api/v1/restAPI/user/activeOnes'.\n* additional systemdb for managing/monitoring purposes (or if you need a backoffice for other dbs)\n* a model returns mongoose schema, mongo model, and optionally systemdb flag (systemdb: true -\u003e this model is only für systemdb, systemdb: false -\u003e only for the other dbs, not set -\u003e for otherdbs and systemdb)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkillercodemonkey%2Fnodejs-restapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkillercodemonkey%2Fnodejs-restapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkillercodemonkey%2Fnodejs-restapi/lists"}