{"id":19206317,"url":"https://github.com/fraigo/node-express-rest-api-example","last_synced_at":"2025-05-12T17:26:33.134Z","repository":{"id":33911056,"uuid":"163541283","full_name":"fraigo/node-express-rest-api-example","owner":"fraigo","description":"A Basic Node.js/Express REST API implementation example","archived":false,"fork":false,"pushed_at":"2023-03-04T03:03:27.000Z","size":37,"stargazers_count":79,"open_issues_count":3,"forks_count":71,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-20T14:43:37.131Z","etag":null,"topics":["expressjs","nodejs","rest-api"],"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/fraigo.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,"zenodo":null}},"created_at":"2018-12-29T21:10:49.000Z","updated_at":"2025-03-20T06:19:23.000Z","dependencies_parsed_at":"2025-04-20T14:51:49.806Z","dependency_job_id":null,"html_url":"https://github.com/fraigo/node-express-rest-api-example","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/fraigo%2Fnode-express-rest-api-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraigo%2Fnode-express-rest-api-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraigo%2Fnode-express-rest-api-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraigo%2Fnode-express-rest-api-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fraigo","download_url":"https://codeload.github.com/fraigo/node-express-rest-api-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253786073,"owners_count":21964087,"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":["expressjs","nodejs","rest-api"],"created_at":"2024-11-09T13:15:30.699Z","updated_at":"2025-05-12T17:26:33.106Z","avatar_url":"https://github.com/fraigo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-express-rest-api-example\n\nA Basic Node.js/Express REST API implementation example.\n\nFull Tutorial at https://developerhowto.com/2018/12/29/build-a-rest-api-with-node-js-and-express-js/\n\n# Prerequisites\n\nFor Windows\n\n* Python 2.7 (for microsoft build tools)\n* Install Microsoft build tools (to build sqlite using node-gyp)\n  * Instructions here https://github.com/nodejs/node-gyp#on-windows\n  * Or install using npm (`npm install --global windows-build-tools`)\n* Node-gyp (`npm install --global node-gyp`)\n\n# Usage\n\n* Run `npm install` to installl dependencies\n* Run `npm run start` to start the local server\n* Load `http://localhost:8000` to test the endpoint. It will display a json result `{\"message\":\"Ok\"}`\n\n# API Endpoints\n\n## GET /api/users\n\nGet a list of users\n\n```json\n{\n  \"message\": \"success\",\n  \"data\": [\n    {\n      \"id\": 1,\n      \"name\": \"admin\",\n      \"email\": \"admin@example.com\",\n      \"password\": \"a66abb5684c45962d887564f08346e8d\"\n    },\n    {\n      \"id\": 2,\n      \"name\": \"user\",\n      \"email\": \"user@example.com\",\n      \"password\": \"4da49c16db42ca04538d629ef0533fe8\"\n    }\n  ]\n}\n```\n\n## GET /api/user/{id}\n\nGet user information by user id\n\n```json\n{\n  \"message\": \"success\",\n  \"data\": {\n    \"id\": 1,\n    \"name\": \"admin\",\n    \"email\": \"admin@example.com\",\n    \"password\": \"a66abb5684c45962d887564f08346e8d\"\n  }\n}\n```\n\n## POST /api/user/\n\nTo create a new user based on POST data (x-www-form-url-encoded)\n\n* name: User name\n* email: User email\n* password: User password\n\n![Postman example](https://developerhowto.com/wp-content/uploads/2018/12/PostMan-POST-request.png)\n\n\n## PATCH /api/user/{id}\n\nTo update user data by id, based on POST data (x-www-form-url-encoded)\n\n* name: User name\n* email: User email\n* password: User password\n\nYou can send only one attribute to update, the rest of the info remains the same. \n\nIn this example, using CURL you can update the user email:\n\n```bash\ncurl -X PATCH -d \"email=user@example1.com\" http://localhost:8000/api/user/2\n```\n\n## DELETE /api/user/{id}\n\nTo remove a user from the database by user id. \n\nThis example is using the `curl` command line\n\n\n```bash\ncurl -X \"DELETE\" http://localhost:8000/api/user/2\n```\n\nThe result is:\n\n`{\"message\":\"deleted\",\"rows\":1}`\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffraigo%2Fnode-express-rest-api-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffraigo%2Fnode-express-rest-api-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffraigo%2Fnode-express-rest-api-example/lists"}