{"id":19273706,"url":"https://github.com/yusufshakeel/node-api-project","last_synced_at":"2026-04-07T08:01:58.544Z","repository":{"id":44107404,"uuid":"195712882","full_name":"yusufshakeel/node-api-project","owner":"yusufshakeel","description":"This is a simple Node project to create a simple API server.","archived":false,"fork":false,"pushed_at":"2023-01-07T07:44:39.000Z","size":1128,"stargazers_count":1,"open_issues_count":19,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-23T20:44:20.739Z","etag":null,"topics":["api","express","expressjs","javascript","jest","jwt","mongoose","node","nodejs","restful-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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yusufshakeel.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":"2019-07-08T01:00:34.000Z","updated_at":"2019-08-17T22:28:16.000Z","dependencies_parsed_at":"2023-02-06T15:00:42.350Z","dependency_job_id":null,"html_url":"https://github.com/yusufshakeel/node-api-project","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yusufshakeel/node-api-project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusufshakeel%2Fnode-api-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusufshakeel%2Fnode-api-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusufshakeel%2Fnode-api-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusufshakeel%2Fnode-api-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusufshakeel","download_url":"https://codeload.github.com/yusufshakeel/node-api-project/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusufshakeel%2Fnode-api-project/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31504897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","express","expressjs","javascript","jest","jwt","mongoose","node","nodejs","restful-api"],"created_at":"2024-11-09T20:43:52.483Z","updated_at":"2026-04-07T08:01:58.529Z","avatar_url":"https://github.com/yusufshakeel.png","language":"JavaScript","funding_links":["https://www.patreon.com/yusufshakeel","https://www.paypal.me/yusufshakeel"],"categories":[],"sub_categories":[],"readme":"# node-api-project\n\nThis is a simple Node project to create a simple API server.\n\n## Prerequisite\n\n* Node \u003e= v8\n* NPM \u003e= v6\n* MongoDB \u003e= v3\n\n## Features of this project\n* User sign up\n* User log in\n* User authentication using JWT (JSON Web Token)\n* Update user account data (own account) only after log in\n* View all users (public info) using pagination\n* View user (public info) using id\n* View full user account data (own account) only after log in\n* Delete user account (own account) only after log in\n\n## Tests\nTest code of this project is inside the `tests` directory.\n\nUsing the following for testing:\n* Jest\n* Supertest\n\n## How to use this project?\n\n1. Download the project code.\n2. Run `npm init` to install the packages.\n3. Setup environment variables\n```\n$ export node_api_project_jwtPrivateKey=secretKey\n$ export node_api_project_PORT=3000\n```\nIf you don't set the PORT then default port 3000 will be used.\n\n4. Run the project `node index.js` or `nodemon`.\n\n\n## APIs\n\n### User - Sign up\n\n```\nPOST /api/users\nHost: localhost:3000\nContent-Type: application/json\n\n{\n    \"first_name\": \"Yusuf\",\n    \"last_name\": \"Shakeel\",\n    \"email\": \"yusufshakeel@example.com\",\n    \"password\": \"root1234\"\n}\n```\n\nResponse\n\n```JSON\n{\n    \"code\": 200,\n    \"status\": \"success\",\n    \"data\": {\n        \"_id\": \"5d29b9e42ef2dc359a2640ee\",\n        \"first_name\": \"Yusuf\",\n        \"last_name\": \"Shakeel\",\n        \"email\": \"yusufshakeel@example.com\"\n    }\n}\n```\n\n### User - Log in\n\n```\nPOST /api/users/login\nHost: localhost:3000\nContent-Type: application/json\n\n{\n    \"email\": \"yusufshakeel@example.com\",\n    \"password\": \"root1234\"\n}\n```\n\nResponse\n\n```JSON\n{\n    \"code\": 200,\n    \"status\": \"success\",\n    \"data\": {\n        \"_id\": \"5d29b9e42ef2dc359a2640ee\",\n        \"first_name\": \"Yusuf\",\n        \"last_name\": \"Shakeel\",\n        \"email\": \"yusufshakeel@example.com\"\n    }\n}\n```\n\nJWT will be present in the header. Check `x-auth-token`.\n\n### User - List all active users\n\n```\nGET /api/users\nHost: localhost:3000\n```\n\nResponse\n\n```JSON\n{\n    \"code\": 200,\n    \"status\": \"success\",\n    \"data\": [\n        {\n            \"_id\": \"5d2461f8e4dd952b8f005b9e\",\n            \"first_name\": \"Yusuf\",\n            \"last_name\": \"Shakeel\"\n        },\n        {\n            \"_id\": \"5d24629cc55c602bc69c5468\",\n            \"first_name\": \"John\",\n            \"last_name\": \"Doe\"\n        },\n        {\n            \"_id\": \"5d2462a7c55c602bc69c5469\",\n            \"first_name\": \"Jane\",\n            \"last_name\": \"Doe\"\n        }\n    ]\n}\n```\n\n### User - User public info by id\n\n```\nGET /api/users/5d2461f8e4dd952b8f005b9e\nHost: localhost:3000\n```\n\nResponse\n\n```JSON\n{\n    \"code\": 200,\n    \"status\": \"success\",\n    \"data\": {\n        \"_id\": \"5d2461f8e4dd952b8f005b9e\",\n        \"first_name\": \"Yusuf\",\n        \"last_name\": \"Shakeel\"\n    }\n}\n```\n\n### User - Full account data (for logged in user)\n\n```\nGET /api/users/me\nHost: localhost:3000\nx-auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZDI0NjFmOGU0ZGQ5NTJiOGYwMDViOWUiLCJpc1VzZXIiOnRydWUsImV4cCI6MTU2MzAxOTUzMSwiaWF0IjoxNTYzMDE1OTMxfQ.EY_5GJzqrfaHAwi6g5kvrA5FUKCXclTD1F0eTpq8ZQk\n```\n\nDon't forget to pass the `x-auth-token` in the header.\n\nResponse\n\n```JSON\n{\n    \"code\": 200,\n    \"status\": \"success\",\n    \"data\": {\n        \"_id\": \"5d2461f8e4dd952b8f005b9e\",\n        \"first_name\": \"Yusuf\",\n        \"last_name\": \"Shakeel\",\n        \"email\": \"yusufshakeel@example.com\",\n        \"account_status\": \"ACTIVE\"\n    }\n}\n```\n\n### User - Update account data (for logged in user)\n\n```\nPUT /api/users\nHost: localhost:3000\nx-auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZDI0NjFmOGU0ZGQ5NTJiOGYwMDViOWUiLCJpc1VzZXIiOnRydWUsImV4cCI6MTU2MzAxOTUzMSwiaWF0IjoxNTYzMDE1OTMxfQ.EY_5GJzqrfaHAwi6g5kvrA5FUKCXclTD1F0eTpq8ZQk\nContent-Type: application/json\n\n{\n    \"first_name\": \"Yusuf\",\n    \"last_name\": \"Shakeel\",\n    \"password\": \"root1234\",\n    \"account_status\": \"ACTIVE\"\n}\n```\n\nDon't forget to pass the `x-auth-token` in the header.\n\nResponse\n\n```JSON\n{\n    \"code\": 200,\n    \"status\": \"success\",\n    \"data\": {\n        \"_id\": \"5d2461f8e4dd952b8f005b9e\",\n        \"first_name\": \"Yusuf\",\n        \"last_name\": \"Shakeel\",\n        \"email\": \"yusufshakeel@example.com\",\n        \"account_status\": \"ACTIVE\"\n    }\n}\n```\n\n### User - Delete account (for logged in user)\n\n```\nDELETE /api/users\nHost: localhost:3000\nx-auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZDI5YzA3MTU4N2NkYzNhOWU4NGZmZDciLCJpc1VzZXIiOnRydWUsImV4cCI6MTU2MzAyMDkzNiwiaWF0IjoxNTYzMDE3MzM2fQ.yjPB2Qe1VIL3iwVJ5XqLtehOVRSReBv2r79ecou9oF0\nContent-Type: application/json\n```\n\nDon't forget to pass the `x-auth-token` in the header.\n\nResponse\n\n```JSON\n{\n    \"code\": 200,\n    \"status\": \"success\",\n    \"data\": \"Account deleted.\"\n}\n```\n\n## License\nIt's free.\n\n[MIT License](https://github.com/yusufshakeel/node-api-project/blob/master/LICENSE) Copyright (c) 2019 Yusuf Shakeel\n\n### Back this project\n\nIf you find this project useful and interesting then please support it on [Patreon](https://www.patreon.com/yusufshakeel).\n\n### Donate\nFeeling generous :-) [Donate via PayPal](https://www.paypal.me/yusufshakeel)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusufshakeel%2Fnode-api-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusufshakeel%2Fnode-api-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusufshakeel%2Fnode-api-project/lists"}