{"id":21581555,"url":"https://github.com/thoughtscript/node-2021","last_synced_at":"2025-07-16T22:30:29.193Z","repository":{"id":215677789,"uuid":"354040397","full_name":"Thoughtscript/node-2021","owner":"Thoughtscript","description":"node-2021-refresh","archived":false,"fork":false,"pushed_at":"2021-04-02T17:32:07.000Z","size":3851,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-01-05T21:25:42.022Z","etag":null,"topics":["api","js","node","rest"],"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/Thoughtscript.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}},"created_at":"2021-04-02T14:18:36.000Z","updated_at":"2024-01-05T21:25:44.765Z","dependencies_parsed_at":"2024-01-05T21:25:44.619Z","dependency_job_id":"091fda3c-14b7-4663-8acf-dbad47ad4ad6","html_url":"https://github.com/Thoughtscript/node-2021","commit_stats":null,"previous_names":["thoughtscript/node-2021"],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thoughtscript%2Fnode-2021","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thoughtscript%2Fnode-2021/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thoughtscript%2Fnode-2021/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thoughtscript%2Fnode-2021/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Thoughtscript","download_url":"https://codeload.github.com/Thoughtscript/node-2021/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226171933,"owners_count":17584910,"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":["api","js","node","rest"],"created_at":"2024-11-24T14:12:54.545Z","updated_at":"2024-11-24T14:12:55.076Z","avatar_url":"https://github.com/Thoughtscript.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-2021\n\n[![](https://img.shields.io/badge/Node.js-14.16.0-yellowgreen.svg)](https://nodejs.org/en/)\n\nnode-2021-refresh.\n\nThis removes `body-parser` module.\n\n\u003e Note: This necessitates setting `Content-Type` to `JSON` in your PUT requests (previously, you could send over anything in the body as a String too).\n\n\u003e Note: See security comment below for \"injection-like\" directory traversal protections.\n\n\u003e This is not production-worthy but is a helpful scaffold for boilerplate.\n\n## Use\n\n```zsh\nnpm i\nnpm run start\nnpm run stop-unix\nnpm run stop-win\n```\n\nTo run tests:\n```zsh\nnpm run start\nnpm run tests\n```\n\nYou will see:\n```cmd\nGET /data/cats/ 404 4.267 ms - 149\nPUT /data/cats 201 20.348 ms - 69\nGET /data/cats/c922e669-c677-4bb3-aa8d-52d78dbcb0c7 200 3.600 ms - 45\nDELETE /data/cats/c922e669-c677-4bb3-aa8d-52d78dbcb0c7 200 1.378 ms - 14\n```\n\n```cmd\n======= GET request made to http:localhost:7777/data/cats/\n\nSTATUS: 404\n\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n\u003cmeta charset=\"utf-8\"\u003e\n\u003ctitle\u003eError\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cpre\u003eCannot GET /data/cats/\u003c/pre\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\n======= PUT request made to http:localhost:7777/data/cats\n\nSTATUS: 201\n\n{\"status\":201,\"oid\":\"c922e669-c677-4bb3-aa8d-52d78dbcb0c7\",\"size\":17}\n\n======= GET request made to http:localhost:7777/data/cats/c922e669-c677-4bb3-aa8d-52d78dbcb0c7\n\nSTATUS: 200\n\n{\"status\":200,\"data\":\"{\\\"name\\\":\\\"hello!\\\"}\"}\n\n======= DELETE request made to http:localhost:7777/data/cats/c922e669-c677-4bb3-aa8d-52d78dbcb0c7\n\nSTATUS: 200\n\n{\"status\":200}\n```\n\nSome PNG's illustrating this and Postman setup are in [images](./images).\n\n## API Endpoints\n\n1. The main app runs off port `8888`.\n1. The Express app (and routes) / API is on `7777`.\n1. These can be configured in `config.js`.\n1. The API creates, removes, and retrieves simple blob-like object files (un-encrypted) within a defined repository (enclosing dir).\n1. Express request params (`req.params`) is \"smart enough\" (read: secure-enough out of the box) to also remove injection-attack-like symbols/chars from your PUT request. In other words, `localhost:7777/data/..catas/` will simply created a directory with String name `..catas` rather than traversing the directory tree up. Likewise, `localhost:7777/data/../../catas/` will simply return an error.\n\n### Upload an Object\n\n```URL\nPUT localhost:7777/data/12312fy7yi\n```\n\n```Body\n{\n\t\"object\": \"Test!\"\n}\n```\n\n#### Response\n\n```\n{\n    \"status\": 201,\n    \"oid\": \"7db07cc0-6588-4320-9da6-f0f6deffc860\",\n    \"size\": 7\n}\n```\n\n### Download an Object\n\n```\nGET localhost:7777/data/123h89hahf2324/132132321312\n```\n\n#### Response\n\n```\n{\n    \"status\": 200,\n    \"data\": \"Hello!\"\n}\n```\n\nObjects that are not on the server will return a `404 Not Found`.\n\n### Delete an Object\n\n```\nDELETE localhost:7777/data/12312fy7yi/ee766e89-e6c9-4eec-a78e-88d7baf657d7\n```\n\n#### Response\n\n```\n{\n    \"status\": 200\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoughtscript%2Fnode-2021","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthoughtscript%2Fnode-2021","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoughtscript%2Fnode-2021/lists"}