{"id":22164838,"url":"https://github.com/net2devcrypto/nodejs-database-app","last_synced_at":"2025-03-24T16:12:43.833Z","repository":{"id":185135323,"uuid":"673031791","full_name":"net2devcrypto/NodeJS-Database-App","owner":"net2devcrypto","description":"A simple yet powerful NodeJS Database App. Create a new local JSON format database, read and write to it using POST API endpoints!!!","archived":false,"fork":false,"pushed_at":"2023-08-01T17:35:41.000Z","size":25,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-29T21:43:30.809Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/net2devcrypto.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-31T17:58:27.000Z","updated_at":"2023-08-01T17:32:39.000Z","dependencies_parsed_at":"2025-01-29T21:42:19.857Z","dependency_job_id":null,"html_url":"https://github.com/net2devcrypto/NodeJS-Database-App","commit_stats":null,"previous_names":["net2devcrypto/nodejs-database-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/net2devcrypto%2FNodeJS-Database-App","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/net2devcrypto%2FNodeJS-Database-App/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/net2devcrypto%2FNodeJS-Database-App/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/net2devcrypto%2FNodeJS-Database-App/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/net2devcrypto","download_url":"https://codeload.github.com/net2devcrypto/NodeJS-Database-App/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245304872,"owners_count":20593626,"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-12-02T05:10:59.707Z","updated_at":"2025-03-24T16:12:43.800Z","avatar_url":"https://github.com/net2devcrypto.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NodeJS-Database-App\n\n👑 A simple yet powerful NodeJS Database App. Create a new local JSON formatted database, read and write to it using POST API endpoints!!!\n\n\u003cimg src=\"https://raw.githubusercontent.com/net2devcrypto/misc/main/dbapp.png\" width=\"450\" height=\"225\"\u003e\n\n** THE FILES ATTACHED TO THIS REPO ARE FOR EDUCATIONAL PURPOSES ONLY **\n\n\u003ch2\u003eHow to Start Database Server\u003c/h2\u003e\n\n## Step 1\n\nDownload the contents of this repo or do a git clone, extract the contents and navigate to the extracted folder and install dependencies:\n\n```shell\nnpm i\n```\n\n## Step 2\n\n(Optional) Change the listening port on the app.js file if needed. Default Port 5000\n\n```\nconst server = app.listen(5000, function() {\n```\n\n## Step 3\n\nRun the Database App\n\n```shell\nnode app.js\n```\n\n\u003ch2\u003eHow to Use\u003c/h2\u003e\n\n\u003ch3\u003eWrite to the Database\u003c/h3\u003e\n\nSend a API Post with your data along with the database name, if there's no database file created it will auto create it.\n\nPOST API ENDPOINT:   \u003ch4\u003e/sendtodb\u003c/h4\u003e\n\nSample request:\n\nCreate a database of 100 users;\n\nWith Javascript\n\n\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/6/6a/JavaScript-logo.png\" width=\"100\" height=\"100\"\u003e\n\n\"dbname\" is the database file name. ( Will be auto created if it doesn't exist )\n\n```\n  const dburl = \"http://localhost:5000\";\n\n  async function writedb() {\n    let total = 100;\n    let dbname = 'users'\n    for (let i = 0; i \u003c total; i++) {\n      let number = i + 1;\n\n      let entry = {\n        name: 'User' + number,\n        ip: '10.10.1.' + number,\n        dept: 'developers'\n      }\n\n      const url = dburl + \"/sendtodb\";\n      const config = {\n        method: \"POST\",\n        body: JSON.stringify({\n          database: dbname,\n          entry: entry\n        }),\n        headers: {\n          \"content-type\": \"application/json\",\n        },\n      };\n      await fetch(url, config);\n    }\n  }\n```\n\nWith Python:\n\n\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Python-logo-notext.svg/1869px-Python-logo-notext.svg.png\" width=\"100\" height=\"100\"\u003e\n\n```python\nimport requests\nimport json\n\ndburl = \"http://localhost:5000\"\nheaders =  {'Content-Type': 'application/json'}\n\ndef writedb():\n    total = 100\n    dbname = 'users'\n    try:\n        \n        for i in range(total):\n            number = i + 1\n            entry = {\n                'name': 'User' + number,\n                'ip': '10.10.1.' + number,\n                'dept': 'developers'\n            }\n            \n            body = {\n                'database': dbname,\n                'entry': entry\n            }\n            \n            url = dburl + \"/sendtodb\"\n            payload = json.dumps(body)\n            requests.request(\"POST\", url, headers=headers, data=payload)\n       \n    except:\n        print('Failed to Store in DB')\n```\n\nEXPECTED: \n\nYour Database file will be located in the same app folder:\n\n\u003cimg src=\"https://raw.githubusercontent.com/net2devcrypto/misc/main/userdb.png\" width=\"550\" height=\"325\"\u003e\n\n\u003ch3\u003eRead from the Database\u003c/h3\u003e\n\nPOST API ENDPOINT:   \u003ch4\u003e/readdb\u003c/h4\u003e\n\nSend a API Post with the database name.\n\nSample request:\n\nReturns the \"users\" database\n\nWith Javascript\n\n\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/6/6a/JavaScript-logo.png\" width=\"100\" height=\"100\"\u003e\n\n```\n  const dburl = \"http://localhost:5000\";\n\n  async function readdb() {\n    let dbname = 'users'\n    const url = dburl + \"/readdb\";\n    const config = {\n      method: \"POST\",\n      body: JSON.stringify({\n        database: dbname\n      }),\n      headers: {\n        \"content-type\": \"application/json\",\n      },\n    };\n    let response = await fetch(url, config);\n    let output = await response.json()\n    console.log(output)\n    return output;\n  }\n```\n\nWith Python:\n\n\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Python-logo-notext.svg/1869px-Python-logo-notext.svg.png\" width=\"100\" height=\"100\"\u003e\n\n```python\nimport requests\nimport json\n\ndburl = \"http://localhost:5000\"\nheaders =  {'Content-Type': 'application/json'}\n\ndef readdb():\n    dbname = 'users'\n    try:\n        body = {\n            'database': dbname\n        }\n            \n        url = dburl + \"/readdb\"\n        payload = json.dumps(body)\n        response = requests.request(\"POST\", url, headers=headers, data=payload)\n        data = response.json()\n        print(data)\n        return data\n       \n    except:\n        print('Failed to Read DB')\n```\n\nYou should receive the entire database array as a return. \n\n\u003ch3\u003eGet a single item from the database\u003c/h3\u003e\n\nSend a API Post with the database name, the key and the value you are looking for. Returns the User's 30 info stored on the database.\n\nPOST API ENDPOINT:   \u003ch4\u003e/fetchfromdb\u003c/h4\u003e\n\nSample request:\n\nWith Javascript\n\n\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/6/6a/JavaScript-logo.png\" width=\"100\" height=\"100\"\u003e\n\n```\n  const dburl = \"http://localhost:5000\";\n\n  async function fetchdb() {\n    let dbname = 'users'\n    let key = 'name'\n    let value = 'User30'\n    const url = dburl + \"/fetchfromdb\";\n    const config = {\n      method: \"POST\",\n      body: JSON.stringify({\n        database: dbname,\n        key: key,\n        entry: value\n      }),\n      headers: {\n        \"content-type\": \"application/json\",\n      },\n    };\n    let response = await fetch(url, config);\n    let output = await response.json()\n    console.log(output)\n    return output\n  }\n```\n\nWith Python:\n\n\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Python-logo-notext.svg/1869px-Python-logo-notext.svg.png\" width=\"100\" height=\"100\"\u003e\n\n```python\nimport requests\nimport json\n\ndburl = \"http://localhost:5000\"\nheaders =  {'Content-Type': 'application/json'}\n\ndef fetchdb():\n    dbname = 'users'\n    key = 'name'\n    value = 'User30'\n    try:\n        body = {\n            'database': dbname,\n            key: value,\n        }\n        url = dburl + \"/fetchfromdb\"\n        payload = json.dumps(body)\n        response = requests.request(\"POST\", url, headers=headers, data=payload)\n        data = response.json()\n        print(data)\n        return data\n       \n    except:\n        print('Failed to Read DB')\n```\n\n\nYou should receive the database info stored for user 30 as a return. \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnet2devcrypto%2Fnodejs-database-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnet2devcrypto%2Fnodejs-database-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnet2devcrypto%2Fnodejs-database-app/lists"}