{"id":22170892,"url":"https://github.com/elhanarinc/resource-challenge","last_synced_at":"2026-02-12T14:33:05.731Z","repository":{"id":42680832,"uuid":"163108732","full_name":"elhanarinc/resource-challenge","owner":"elhanarinc","description":"Challenge written with Node.js/Express.js Framework","archived":false,"fork":false,"pushed_at":"2025-01-16T17:19:54.000Z","size":175,"stargazers_count":2,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-20T18:55:28.452Z","etag":null,"topics":["expressjs","javascript","mongodb","mongoose","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elhanarinc.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-12-25T20:08:18.000Z","updated_at":"2024-11-05T07:52:36.000Z","dependencies_parsed_at":"2025-01-29T22:37:20.570Z","dependency_job_id":null,"html_url":"https://github.com/elhanarinc/resource-challenge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/elhanarinc/resource-challenge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elhanarinc%2Fresource-challenge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elhanarinc%2Fresource-challenge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elhanarinc%2Fresource-challenge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elhanarinc%2Fresource-challenge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elhanarinc","download_url":"https://codeload.github.com/elhanarinc/resource-challenge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elhanarinc%2Fresource-challenge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29368690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T08:51:36.827Z","status":"ssl_error","status_checked_at":"2026-02-12T08:51:26.849Z","response_time":55,"last_error":"SSL_read: 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":["expressjs","javascript","mongodb","mongoose","nodejs"],"created_at":"2024-12-02T06:56:31.756Z","updated_at":"2026-02-12T14:33:05.718Z","avatar_url":"https://github.com/elhanarinc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nodejs Challenge\n\nCoding challenge written with Node.js/Express.js Framework.\n\nThis project assumes you had already installed these tools:\n1. [node.js](https://nodejs.org/en/)\n2. [express.js](https://expressjs.com/)\n\nThird party packages, tools, etc.\n1. [dotenv](https://www.npmjs.com/package/dotenv) for reading environment variables.\n2. [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken) for user authentication.\n3. [bcrypt](https://www.npmjs.com/package/bcrypt) for password hashing.\n4. [mongoose](https://www.npmjs.com/package/mongoose) for ORM.\n5. [nodemon](https://www.npmjs.com/package/nodemon) for auto restarting and persistent uptime.\n\nIn order to use API, you need a mongodb instance which could be on local your machine or [mongoDB-Atlas](https://cloud.mongodb.com). After that you need to create four different collections.\n* Collection used for `users` endpoint\n* Collection used for `resource` endpoint\n* Test replica of `users`\n* Test replica of `resource`\n\nI have used an `.env` file for the project in order to seperate `test` and `production` environments and sample configuration for sample `.env` file:\n\n```\nDB_CONN_USERNAME=user\nDB_CONN_PASS=password\n\nDB_CONN_URL=sample_mongo_url\nDB_CONN_DBNAME=sample_database_name\n\nDB_COLL_RESOURCE_TEST=resource-test\nDB_COLL_RESOURCE_PROD=resource\n\nDB_COLL_USERS_TEST=users-test\nDB_COLL_USERS_PROD=users\n\nJWT_SECRET=sample-jwt-secret\n```\n\nBelow are the commands that is need for running the API:\n* `npm start` for production\n* `npm test` for running tests\n\nThere are different endpoints for this API:\n1. `/users/register`\n* This endpoint accepts *POST* request.\n* If user data is not on db it hashes the password, inserts the user data into db and returns a **token**.\n* Body Params:\n```\n{\n\t\"name\": \"deneme\",\n\t\"email\": \"deneme@gmail.com\",\n\t\"password\": \"deneme\"\n}\n```\n\n2. `/users/login`\n* This endpoint accepts *POST* request.\n* If user data is on db, it returns a **token**.\n* Body Params:\n```\n{\n\t\"email\": \"deneme@gmail.com\",\n\t\"password\": \"deneme\"\n}\n```\n\n3. `/users/info`\n* This endpoint accepts *GET* request.\n* This endpoint is for debug, checks the user info on the db.\n* No body params, only `x-access-token` on header.\n\n\n4. `/users/drop`\n* This endpoint accepts *GET* request.\n* This endpoint is for debug, clears `users` collection.\n* No body params.\n\n5. `/users/show`\n* This endpoint accepts *GET* request.\n* This endpoint is for debug, shows `users` collection.\n* No body params\n\n6. `/resource/insert`\n* This endpoint accepts *POST* request.\n* If the token is valid, it inserts the `number` parameter into user's `resource` data.\n* Header: `x-access-token: {sample token}`\n* Body Params:\n```\n{\n\t\"number\": 1\n}\n```\n\n7. `/resource/show`\n* This endpoint accepts *GET* request.\n* This endpoint shows `resource` collection.\n* No body params, only `x-access-token` on header.\n\n1. `/resource/drop`\n* This endpoint accepts *GET* request.\n* This endpoint is for debug, clears `resource` collection.\n* No params.\n\n\n**Useful information about project:**\n```\n* API URL: https://zeplin-challenge.herokuapp.com/\n* Web Server: Heroku\n* Database: MongoDB Atlas\n* App Framework: Node.js/Express.js\n* CI/CD: Codeship\n* Test framework: Mocha and Chai\n```\n\n**References**\n1. https://medium.freecodecamp.org/securing-node-js-restful-apis-with-json-web-tokens-9f811a92bb52\n2. https://scotch.io/tutorials/test-a-node-restful-api-with-mocha-and-chai\n3. https://blog.codeship.com/heroku-github-nodejs-deployment/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felhanarinc%2Fresource-challenge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felhanarinc%2Fresource-challenge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felhanarinc%2Fresource-challenge/lists"}