{"id":19540880,"url":"https://github.com/dimpiax/sh-market-api","last_synced_at":"2026-04-09T22:50:14.242Z","repository":{"id":147831343,"uuid":"87091308","full_name":"dimpiax/sh-market-api","owner":"dimpiax","description":"Second-hand market API","archived":false,"fork":false,"pushed_at":"2018-10-17T13:16:22.000Z","size":749,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-08T18:41:35.158Z","etag":null,"topics":["babel","eslint","flow","nodejs"],"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/dimpiax.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":"2017-04-03T15:42:41.000Z","updated_at":"2022-04-08T22:49:36.000Z","dependencies_parsed_at":"2023-05-27T15:45:14.165Z","dependency_job_id":null,"html_url":"https://github.com/dimpiax/sh-market-api","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2Fsh-market-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2Fsh-market-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2Fsh-market-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2Fsh-market-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimpiax","download_url":"https://codeload.github.com/dimpiax/sh-market-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240795006,"owners_count":19858725,"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":["babel","eslint","flow","nodejs"],"created_at":"2024-11-11T03:07:43.998Z","updated_at":"2026-04-09T22:50:09.208Z","avatar_url":"https://github.com/dimpiax.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Second-hand market API\n#### prototype\n\nSecond-hand goods market API.\n\nAPI has next endpoints:\n* register\n* auth\n* tags\n* advertisements\n\n## Running\nAfter project cloning and installing dependencies, you have to run server by:\n`npm start`.\n\nIn **development** environment doesn't use cluster mode.\n\nIn **production** environment, use only **builded** package. You need to installed **pm2** in your work environment and run `pm2 start index.js -i 0` script. It will start server in cluster mode, using available CPUs.\n\n## Mongo Shell script\nMongoDB shell version must be \u003e= 3.4.2\n\nGo to `scripts/database/mongodb/` directory and execute there the command `mongo install_bd.js`.\n\n## Error messages\nSystem has feature to humanize error messages, there is hardcoded default messages model, it uses if no-one translation found. If error is not described anywhere, it has format `region:type`.\n\nExternal document located at `assets/docs/errorMessages.json`, which has strict structure to translate errors relatively to language. If defined language at `user` or at query is absent, system uses `en` as default.\n\nHere is something special to know: messages are support template literals. I.e.:\n`Email (${email}) or password (${passwd}) are wrong.`, where ${key} - is passed value through error.\n\n## Example\nRequest examples in curl.\n\nQuery:\n\n+ lang: error message language priority\n+ token: for `adverts` request\n\n### register\n###### Register new user\n```curl\ncurl -XPOST http://localhost:3000/apiv1/register?lang=es -H 'Content-Type: application/json' -d '{ \"name\": \"dimpiax\", \"email\": \"dimpiax@gmail.com\", \"passwd\": \"root\", \"lang\": \"UA\" }'\n```\n\n### auth\n###### Auth user\nReturns `AUTH_TOKEN`\n```curl\ncurl -XPOST http://localhost:3000/apiv1/auth -H 'Content-Type: application/json' -d '{ \"email\": \"dimpiax@gmail.com\", \"passwd\": \"root\" }'\n```\n\n### tags\n###### Get existed unique tags\n```curl\ncurl -XGET http://localhost:3000/apiv1/adverts/tags?lang=es\\\u0026token=AUTH_TOKEN\n```\n\n### advertisements\n###### Get advertisements\nQuery has additional keys:\n\nDocuments includes in response that satisfy conditions:\n\n+ name *(*string*)*: starts by given string\n+ price *(*string | double*)*: partly or whole range for `price` property\n+ toSell *(*boolean*)*: advertisement type\n+ tag *(*string*)*: value that exist in `tags` array property\n+ limit *(*number*)*: limit documents count in response\n+ start *(*number*)*: show page relatively to limit count. I.e.: start is **5** and limit is **10**, documents will be shown from *50* index.\n\nDocuments can be sorted:\n\n+ sort *(*string*)*: ascending sorting by set specific property\n\n#### Requests:\n\n+ paging, sorting, price interval, tag\n```curl\ncurl -XGET http://localhost:3000/apiv1/adverts?token=AUTH_TOKEN\\\u0026start=0\\\u0026limit=2\\\u0026sort=toSell\\\u0026price=10-230.15\\\u0026tag=motor\n```\n+ advertisement type\n```curl\ncurl -XGET http://localhost:3000/apiv1/adverts?token=AUTH_TOKEN\\\u0026toSell=false\n```\n\n### Technical information\nProject implemented on JavaScript, using the latest ES features, dated on the latest commit.\n\nIts development environment based on: Babel, Flow, ESLint.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimpiax%2Fsh-market-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimpiax%2Fsh-market-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimpiax%2Fsh-market-api/lists"}