{"id":17651758,"url":"https://github.com/diegovictor/ecoleta-api","last_synced_at":"2025-05-07T07:21:56.669Z","repository":{"id":39788859,"uuid":"268972109","full_name":"DiegoVictor/ecoleta-api","owner":"DiegoVictor","description":"scriptProject built during Rocketseat's Next Level Week #1","archived":false,"fork":false,"pushed_at":"2025-03-24T02:26:31.000Z","size":4754,"stargazers_count":3,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T07:34:23.890Z","etag":null,"topics":["api","coverage-report","database","ecoleta","friendly-errors","javascritpt","js","nlw","nlw-booster","node","nodejs","rocketseat","seeds","sqlite","ts","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/DiegoVictor.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}},"created_at":"2020-06-03T02:41:34.000Z","updated_at":"2025-03-24T02:26:34.000Z","dependencies_parsed_at":"2024-01-15T04:37:19.172Z","dependency_job_id":"6e5d82ab-a39c-46a3-bb76-daac667f87d1","html_url":"https://github.com/DiegoVictor/ecoleta-api","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/DiegoVictor%2Fecoleta-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fecoleta-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fecoleta-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fecoleta-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DiegoVictor","download_url":"https://codeload.github.com/DiegoVictor/ecoleta-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831462,"owners_count":21810808,"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":["api","coverage-report","database","ecoleta","friendly-errors","javascritpt","js","nlw","nlw-booster","node","nodejs","rocketseat","seeds","sqlite","ts","typescript"],"created_at":"2024-10-23T11:43:30.382Z","updated_at":"2025-05-07T07:21:56.649Z","avatar_url":"https://github.com/DiegoVictor.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [API] Ecoleta\n[![CircleCI](https://img.shields.io/circleci/build/github/DiegoVictor/ecoleta-api?style=flat-square\u0026logo=circleci)](https://app.circleci.com/pipelines/github/DiegoVictor/ecoleta-api?branch=main)\n[![sqlite3](https://img.shields.io/badge/sqlite-5.1.7-003b57?style=flat-square\u0026logo=sqlite\u0026logoColor=white)](https://www.sqlite.org)\n[![typescript](https://img.shields.io/badge/typescript-5.5.4-3178c6?style=flat-square\u0026logo=typescript)](https://www.typescriptlang.org/)\n[![eslint](https://img.shields.io/badge/eslint-8.57.0-4b32c3?style=flat-square\u0026logo=eslint)](https://eslint.org/)\n[![airbnb-style](https://flat.badgen.net/badge/style-guide/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)\n[![jest](https://img.shields.io/badge/jest-29.7.0-brightgreen?style=flat-square\u0026logo=jest)](https://jestjs.io/)\n[![coverage](https://img.shields.io/codecov/c/gh/DiegoVictor/ecoleta-api?logo=codecov\u0026style=flat-square)](https://codecov.io/gh/DiegoVictor/ecoleta-api)\n[![MIT License](https://img.shields.io/badge/license-MIT-green?style=flat-square)](https://raw.githubusercontent.com/DiegoVictor/ecoleta-api/main/LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\u003cbr\u003e\n[![Run in Insomnia}](https://insomnia.rest/images/run.svg)](https://insomnia.rest/run/?label=Ecoleta\u0026uri=https%3A%2F%2Fraw.githubusercontent.com%2FDiegoVictor%2Fecoleta-api%2Fmain%2FInsomnia_2024-06-30.json)\n\nResponsible for provide data to the [`web`](https://github.com/DiegoVictor/ecoleta-web) and [`mobile`](https://github.com/DiegoVictor/ecoleta-app) front-ends. Allow to register points and set the items type that point receive. The app has friendly errors, validation, also a simple versioning was made.\n\n## Table of Contents\n* [Installing](#installing)\n  * [Configuring](#configuring)\n    * [SQLite](#sqlite)\n      * [Migrations](#migrations)\n      * [Seeds](#seeds)\n    * [.env](#env)\n* [Usage](#usage)\n  * [Error Handling](#error-handling)\n    * [Errors Reference](#errors-reference)\n  * [Versioning](#versioning)\n  * [Routes](#routes)\n    * [Requests](#requests)\n* [Running the tests](#running-the-tests)\n  * [Coverage report](#coverage-report)\n\n# Installing\nEasy peasy lemon squeezy:\n```\n$ yarn\n```\nOr:\n```\n$ npm install\n```\n\u003e Was installed and configured the [`eslint`](https://eslint.org/) and [`prettier`](https://prettier.io/) to keep the code clean and patterned.\n\n## Configuring\nThe application use just one databases: [SQLite](https://www.sqlite.org/index.html). For the fastest setup is recommended to use [docker-compose](https://docs.docker.com/compose/), you just need to up all services:\n```\n$ docker-compose up -d\n```\n\n### SQLite\nStore the points and point's items. For more information to how to setup your database see:\n* [knexfile.js](http://knexjs.org/#knexfile)\n\u003e You can find the application's `knexfile.js` file in the root folder.\n\n#### Migrations\nRemember to run the SQLite database migrations:\n```\n$ npx knex migrate:latest --knexfile knexfile.ts\n```\n\u003e See more information on [Knex Migrations](http://knexjs.org/#Migrations).\n\nOr simply:\n```\n$ yarn knex:migrate\n```\n\n#### Seeds\nAlso, remember to run the seeds, it will create some default items.\n```\n$ npx knex seed:run --knexfile knexfile.ts\n```\n\u003e Read more on [Seed CLI](http://knexjs.org/#Seeds-CLI)\n\nOr simply:\n```\n$ yarn knex:seed\n```\n\n### .env\nIn this file you may configure your app's url and port, also a url to documentation (this will be returned with error responses, see [error section](#error-handling)). Rename the `.env.example` in the root directory to `.env` then just update with your settings.\n\n|key|description|default\n|---|---|---\n|APP_URL|App's url, when testing the [mobile version](https://github.com/DiegoVictor/ecoleta-app) on devices is strongly recommended to set this key to your [Expo](https://docs.expo.io/) url (e.g. `192.168.0.6`)|`http://localhost`\n|APP_PORT|Port number where the app will run.|`3333`\n|NODE_ENV|App environment.|`development`\n|DOCS_URL|An url to docs where users can find more information about the app's internal code errors.|`https://github.com/DiegoVictor/ecoleta-api#errors-reference`\n\n# Usage\nTo start up the app run:\n```\n$ yarn dev:server\n```\nOr:\n```\n$ npm run dev:server\n```\n\n## Error Handling\nInstead of only throw a simple message and HTTP Status Code this API return friendly errors:\n```json\n{\n  \"statusCode\": 404,\n  \"error\": \"Not Found\",\n  \"message\": \"Point not found\",\n  \"code\": 144,\n  \"docs\": \"https://github.com/DiegoVictor/ecoleta-api#errors-reference\"\n}\n```\n\u003e Errors are implemented with [@hapi/boom](https://github.com/hapijs/boom).\n\u003e As you can see a url to error docs are returned too. To configure this url update the `DOCS_URL` key from `.env` file.\n\u003e In the next sub section ([Errors Reference](#errors-reference)) you can see the errors `code` description.\n\n### Errors Reference\n|code|message|description\n|---|---|---\n|144|Point not found|The `id` sent not references an existing point in the database.\n\n## Versioning\nA simple versioning was made. Just remember to set after the `host` the `/v1/` string to your requests.\n```\nGET http://localhost:3333/v1/points\n```\n\n## Routes\n|route|HTTP Method|params|description\n|:---|:---:|:---:|:---:\n|`/items`|GET| - |Lists points' items.\n|`/points`|GET|`city`, `uf` and `items` query parameters.|Lists points.\n|`/points/:id`|GET|`:id` of the point.|Return one point.\n|`/points`|POST|Body with new point [form data](https://developer.mozilla.org/docs/Web/API/FormData) (See insomnia file for good example).|Create a new point.\n\n### Requests\n* `POST /points`\n\nRequest body:\n```multipart\n{\n  \"name\": \"Hackett, Becker and Fadel\",\n  \"email\": \"contact@hbfadel.com\",\n  \"whatsapp\": \"+551540331438\",\n  \"latitude\": -85.8713,\n  \"longitude\": -73.3957,\n  \"city\": \"São Paulo\",\n  \"uf\": \"SP\",\n  \"items\": \"1, 2\"\n  \"image\": \u003cfile\u003e\n}\n```\n\n* `GET /points?city=Sao+Paulo\u0026uf=SP\u0026items=1,2`\n\n# Running the tests\n[Jest](https://jestjs.io/) was the choice to test the app, to run:\n```\n$ yarn test\n```\nOr:\n```\n$ npm run test\n```\n\n## Coverage report\nYou can see the coverage report inside `tests/coverage`. They are automatically created after the tests run.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegovictor%2Fecoleta-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiegovictor%2Fecoleta-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegovictor%2Fecoleta-api/lists"}