{"id":15491551,"url":"https://github.com/chemitaxis/test_rest","last_synced_at":"2025-03-28T16:42:29.014Z","repository":{"id":117205257,"uuid":"101799702","full_name":"chemitaxis/test_rest","owner":"chemitaxis","description":"This is an example for an issue","archived":false,"fork":false,"pushed_at":"2017-08-29T19:39:46.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-19T10:05:25.059Z","etag":null,"topics":[],"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/chemitaxis.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-08-29T19:38:19.000Z","updated_at":"2017-08-29T19:39:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"60a26883-bc8c-4fd5-941b-bb45d0a6d1a4","html_url":"https://github.com/chemitaxis/test_rest","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"c34f9bcc6a9a4294501ebef571e9cc3e36e5fe49"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chemitaxis%2Ftest_rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chemitaxis%2Ftest_rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chemitaxis%2Ftest_rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chemitaxis%2Ftest_rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chemitaxis","download_url":"https://codeload.github.com/chemitaxis/test_rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246068238,"owners_count":20718501,"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":[],"created_at":"2024-10-02T07:54:12.668Z","updated_at":"2025-03-28T16:42:28.961Z","avatar_url":"https://github.com/chemitaxis.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rest_api\n\nA RESTful API generated by [generator-rest](https://github.com/diegohaz/generator-rest).\n\nSee the API's [documentation](DOCS.md).\n\n## Commands\n\nAfter you generate your project, these commands are available in `package.json`.\n\n```bash\nnpm test # test using Jest\nnpm run test:unit # run unit tests\nnpm run test:integration # run integration tests\nnpm run coverage # test and open the coverage report in the browser\nnpm run lint # lint using ESLint\nnpm run dev # run the API in development mode\nnpm run prod # run the API in production mode\nnpm run docs # generate API docs\n```\n\n## Playing locally\n\nFirst, you will need to install and run [MongoDB](https://www.mongodb.com/) in another terminal instance.\n\n```bash\n$ mongod\n```\n\nThen, run the server in development mode.\n\n```bash\n$ npm run dev\nExpress server listening on http://0.0.0.0:9000, in development mode\n```\n\nIf you choose to generate the authentication API, you can start to play with it.\n\u003e Note that creating and authenticating users needs a master key (which is defined in the `.env` file)\n\nCreate a user (sign up):\n```bash\ncurl -X POST http://0.0.0.0:9000/users -i -d \"email=test@example.com\u0026password=123456\u0026access_token=MASTER_KEY_HERE\"\n```\n\nIt will return something like:\n```bash\nHTTP/1.1 201 Created\n...\n{\n  \"id\": \"57d8160eabfa186c7887a8d3\",\n  \"name\": \"test\",\n  \"picture\":\"https://gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=identicon\",\n  \"email\": \"test@example.com\",\n  \"createdAt\": \"2016-09-13T15:06:54.633Z\"\n}\n```\n\nAuthenticate the user (sign in):\n```bash\ncurl -X POST http://0.0.0.0:9000/auth -i -u test@example.com:123456 -d \"access_token=MASTER_KEY_HERE\"\n```\n\nIt will return something like:\n```bash\nHTTP/1.1 201 Created\n...\n{\n  \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\",\n  \"user\": {\n    \"id\": \"57d8160eabfa186c7887a8d3\",\n    \"name\": \"test\",\n    \"picture\": \"https://gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=identicon\",\n    \"email\": \"test@example.com\",\n    \"createdAt\":\"2016-09-13T15:06:54.633Z\"\n  }\n}\n```\n\nNow you can use the `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9` token (it's usually greater than this) to call user protected APIs. For example, you can create a new `article` API using `yo rest:api` and make the `POST /articles` endpoint only accessible to authenticated users. Then, to create a new article you must pass the `access_token` parameter.\n```bash\ncurl -X POST http://0.0.0.0:9000/articles -i -d \"title=Awesome Article\u0026content=Yeah Baby\u0026access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\"\n```\n\nIt will return something like:\n```bash\nHTTP/1.1 201 Created\n...\n{\n  \"id\": \"57d819bfabfa186c7887a8d6\",\n  \"title\": \"Awesome Article\",\n  \"content\": \"Yeah Baby\",\n  \"createdAt\": \"2016-09-13T15:22:39.846Z\",\n  \"updatedAt\":\"2016-09-13T15:22:39.846Z\"\n}\n```\n\n\u003e Some endpoints are only accessible by admin users. To create an admin user, just pass the `role=admin` along to other data when calling `POST /users`.\n\n## Deploy\n\nHere is an example on how to deploy to [Heroku](https://heroku.com) using [Heroku CLI](https://devcenter.heroku.com/articles/heroku-command-line):\n```bash\n# start a new local git repository\ngit init\n\n# create a new heroku app\nheroku apps:create my-new-app\n\n# add heroku remote reference to the local repository\nheroku git:remote --app my-new-app\n\n# add the MongoLab addon to the heroku app\nheroku addons:create mongolab\n\n# set the environment variables to the heroku app (see the .env file in root directory)\nheroku config:set MASTER_KEY=masterKey JWT_SECRET=jwtSecret\n\n# commit and push the files\ngit add -A\ngit commit -m \"Initial commit\"\ngit push heroku master\n\n# open the deployed app in the browser\nheroku open\n```\n\nThe second time you deploy, you just need to:\n\n```bash\ngit add -A\ngit commit -m \"Update code\"\ngit push heroku master\n```\n\n## Directory structure\n\n### Overview\n\nYou can customize the `src` and `api` directories.\n\n```\nsrc/\n├─ api/\n│  ├─ user/\n│  │  ├─ controller.js\n│  │  ├─ index.js\n│  │  ├─ index.test.js\n│  │  ├─ model.js\n│  │  └─ model.test.js\n│  └─ index.js\n├─ services/\n│  ├─ express/\n│  ├─ facebook/\n│  ├─ mongoose/\n│  ├─ passport/\n│  ├─ sendgrid/\n│  └─ your-service/\n├─ app.js\n├─ config.js\n└─ index.js\n```\n\n### src/api/\n\nHere is where the API endpoints are defined. Each API has its own folder.\n\n#### src/api/some-endpoint/model.js\n\nIt defines the Mongoose schema and model for the API endpoint. Any changes to the data model should be done here.\n\n#### src/api/some-endpoint/controller.js\n\nThis is the API controller file. It defines the main router middlewares which use the API model.\n\n#### src/api/some-endpoint/index.js\n\nThis is the entry file of the API. It defines the routes using, along other middlewares (like session, validation etc.), the middlewares defined in the `some-endpoint.controller.js` file.\n\n### services/\n\nHere you can put `helpers`, `libraries` and other types of modules which you want to use in your APIs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchemitaxis%2Ftest_rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchemitaxis%2Ftest_rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchemitaxis%2Ftest_rest/lists"}