{"id":17651749,"url":"https://github.com/diegovictor/meetapp-api","last_synced_at":"2025-05-07T07:22:06.079Z","repository":{"id":98964639,"uuid":"322783233","full_name":"DiegoVictor/meetapp-api","owner":"DiegoVictor","description":"Application built during the Rocketseat GoStack Bootcamp ","archived":false,"fork":false,"pushed_at":"2025-03-12T12:41:06.000Z","size":1764,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T07:34:24.003Z","etag":null,"topics":["api","database","docker","editorconfig","eslint","gostack","javascript","js","meetapp","node","nodejs","postgres","redis","rocketseat"],"latest_commit_sha":null,"homepage":"","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/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-12-19T06:30:58.000Z","updated_at":"2025-03-12T12:41:09.000Z","dependencies_parsed_at":"2025-01-24T04:21:34.690Z","dependency_job_id":"330f6aed-81eb-4478-a9ca-2445c37b0009","html_url":"https://github.com/DiegoVictor/meetapp-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%2Fmeetapp-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fmeetapp-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fmeetapp-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fmeetapp-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DiegoVictor","download_url":"https://codeload.github.com/DiegoVictor/meetapp-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831463,"owners_count":21810809,"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","database","docker","editorconfig","eslint","gostack","javascript","js","meetapp","node","nodejs","postgres","redis","rocketseat"],"created_at":"2024-10-23T11:43:29.414Z","updated_at":"2025-05-07T07:22:06.066Z","avatar_url":"https://github.com/DiegoVictor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [API] Meetapp\n[![CircleCI](https://img.shields.io/circleci/build/github/DiegoVictor/meetapp-api?style=flat-square\u0026logo=circleci)](https://app.circleci.com/pipelines/github/DiegoVictor/meetapp-api?branch=main)\n[![postgres](https://img.shields.io/badge/postgres-8.11.2-326690?style=flat-square\u0026logo=postgresql\u0026logoColor=white)](https://www.postgresql.org/)\n[![redis](https://img.shields.io/badge/redis-4.6.7-d92b21?style=flat-square\u0026logo=redis\u0026logoColor=white)](https://redis.io/)\n[![nodemon](https://img.shields.io/badge/nodemon-3.0.1-76d04b?style=flat-square\u0026logo=nodemon)](https://nodemon.io/)\n[![eslint](https://img.shields.io/badge/eslint-8.46.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.6.2-brightgreen?style=flat-square\u0026logo=jest)](https://jestjs.io/)\n[![coverage](https://img.shields.io/codecov/c/gh/DiegoVictor/meetapp-api?logo=codecov\u0026style=flat-square)](https://codecov.io/gh/DiegoVictor/meetapp-api)\n[![MIT License](https://img.shields.io/badge/license-MIT-green?style=flat-square)](https://raw.githubusercontent.com/DiegoVictor/meetapp-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=Meetapp\u0026uri=https%3A%2F%2Fraw.githubusercontent.com%2FDiegoVictor%2Fmeetapp-api%2Fmain%2FInsomnia_2024-12-06.json)\n\nResponsible for provide data to the [`web`](https://github.com/DiegoVictor/meetapp-web) and [`mobile`](https://github.com/DiegoVictor/meetapp-app) front-ends. Allow users to create their meetups' and/or subscribe to from other users. The app has, pagination, pagination's link header (to previous, next, first and last page), friendly errors, use JWT to logins, validation, also a simple versioning was made.\n\n## Table of Contents\n* [Installing](#installing)\n  * [Configuring](#configuring)\n    * [Redis](#redis)\n    * [Postgres](#postgres)\n      * [Migrations](#migrations)\n      * [Seed](#seed)\n    * [.env](#env)\n* [Usage](#usage)\n  * [Error Handling](#error-handling)\n    * [Errors Reference](#errors-reference)\n  * [Pagination](#pagination)\n    * [Link Header](#link-header)\n    * [X-Total-Count](#x-total-count)\n  * [Bearer Token](#bearer-token)\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 uses two databases: [Postgres](https://www.postgresql.org/) and [Redis](https://redis.io/). 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### Redis\nResponsible to store data utilized by the mail queue. If for any reason you would like to create a Redis container instead of use `docker-compose`, you can do it by running the following command:\n```\n$ docker run --name meetapp-redis -d -p 6379:6379 redis:alpine\n```\n\n### Postgres\nResponsible to store all application data. If for any reason you would like to create a Postgres container instead of use `docker-compose`, you can do it by running the following command:\n```\n$ docker run --name meetapp-postgres -e POSTGRES_PASSWORD=docker -p 5432:5432 -d postgres\n```\n\n#### Migrations\nRemember to run the Postgres database migrations:\n```\n$ npx sequelize db:migrate\n```\nOr:\n```\n$ yarn sequelize db:migrate\n```\n\u003e See more information on [Sequelize Migrations](https://sequelize.org/v5/manual/migrations.html).\n\n#### Seed\nOptionally you can fill the database with some random data:\n```\n$ npx sequelize db:seed:all\n```\nOr:\n```\n$ yarn sequelize db:seed:all\n```\n\n### .env\nIn this file you may configure your Redis database connection, JWT settings, the environment, app's port and 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.|`http://localhost`\n|APP_PORT|Port number where the app will run.|`3333`\n|NODE_ENV|App environment.|`development`\n|JWT_SECRET|A alphanumeric random string. Used to create signed tokens.| -\n|JWT_EXPIRATION_TIME|How long time will be the token valid. See [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken#usage) repo for more information.|`7d`\n|DB_HOST|Postgres host.| `pg`\n|DB_PORT|Postgres port.| `5432`\n|DB_USER|Postgres user.| -\n|DB_PASS|Postgres password.| -\n|DB_NAME|| `meetapp`\n|MAIL_HOST|SMTP service's host.| `smtp.mailtrap.io`\n|MAIL_PORT|SMTP service's port.| `2525`\n|MAIL_USER|SMTP service's user| -\n|MAIL_PASS|SMTP service's password| -\n|REDIS_HOST|Redis host.|`redis`\n|REDIS_PORT|Redis port.|`6379`\n|SEQUELIZE_LOG|Indicates whether sequelize query operation logs should be shown.|`0`\n|DOCS_URL|An url to docs where users can find more information about the app's internal code errors.|`https://github.com/DiegoVictor/meetapp-api#errors-reference`\n\n\n# Usage\nTo start up the app run:\n```\n$ yarn dev:server\n```\nOr:\n```\nnpm run dev:server\n```\nAlso the application has a mail queue, to setup it just remember to run:\n```\n$ npm run queue\n```\nOr:\n```\n$ yarn queue\n```\n\u003e The mail queue send emails to meetups' owner notifying when a user subscribes to it\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\": 401,\n  \"error\": \"Unauthorized\",\n  \"message\": \"Token not provided\",\n  \"code\": 441,\n  \"docs\": \"https://github.com/DiegoVictor/meetapp-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|140|Past dates are not permited|You can't created meetup with past dates.\n|141|The provided banner does not exists|The `banner_id` sent does not references an existing file in the database.\n|142|You can't edit past meetups|Is not permitted update past meetups.\n|143|You can't remove past meetups|Past meetup can't be deleted.\n|144|Meetup does not exists|The provided meetup does not exists.\n|240|Meetup does not exists or is owned by the provided user|Is not possible to create a subscripton from a meetup that not exists or a meetup owned by yourself.\n|241|You can't subscribe to a past meetup|Is not possible to subscribe to past meetups.\n|242|You are already subscribed to this meetup or there is another meetup in the same time|Conflict or hours or you are already subscribed.\n|244|Meetup or user does not exists|You are trying delete a subscription from a meetup or user that not exists.\n|340|Password does not match|You are trying to update the password with wrong old password.\n|341|Email already in use|Email is already registered by another user.\n|440|Password does not match|Wrong password when trying to login.\n|441|Token not provided|The JWT token was not sent.\n|442|Token invalid|The JWT token provided is invalid or expired.\n|444|User not found|The JWT token not correspond to existing user.\n\n## Pagination\nAll the routes with pagination returns 20 records per page, to navigate to other pages just send the `page` query parameter with the number of the page.\n\n* To get the third page of meetups:\n```\nGET http://localhost:3333/v1/meetups?page=3\n```\n\n### Link Header\nAlso in the headers of every route with pagination the `Link` header is returned with links to `first`, `last`, `next` and `prev` (previous) page.\n```\n\u003chttp://localhost:3333/v1/meetups?page=7\u003e; rel=\"last\",\n\u003chttp://localhost:3333/v1/meetups?page=4\u003e; rel=\"next\",\n\u003chttp://localhost:3333/v1/meetups?page=1\u003e; rel=\"first\",\n\u003chttp://localhost:3333/v1/meetups?page=2\u003e; rel=\"prev\"\n```\n\u003e See more about this header in this MDN doc: [Link - HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link).\n\n### X-Total-Count\nAnother header returned in routes with pagination, this bring the total records amount.\n\n## Bearer Token\nA few routes expect a Bearer Token in an `Authorization` header.\n\u003e You can see these routes in the [routes](#routes) section.\n```\nGET http://localhost:3333/v1/subscriptions Authorization: Bearer \u003ctoken\u003e\n```\n\u003e To achieve this token you just need authenticate through the `/sessions` route and it will return the `token` key with a valid Bearer Token.\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/subscriptions\n```\n\n## Routes\n|route|HTTP Method|pagination|params|description|auth method\n|:---|:---:|:---:|:---:|:---:|:---:\n|`/sessions`|POST|:x:|Body with user's `email` and `password`.|Authenticates user, return a Bearer Token and user's id and email.|:x:\n|`/users`|POST|:x:|Body with user's `name`, `email` and `password`.|Create new users.|:x:\n|`/users`|PUT|:x:|Body with user's `name`, `email` and `old_password`, `password` and `confirm_password`.|Update an existing users.|Bearer\n|`/files`|POST|:x:|Multipart payload with a `file` field with a image (See insomnia file for good example).|Upload meetup banner.|Bearer\n|`/meetups`|GET|:heavy_check_mark:|`page` query parameter.|Lists meetups.|Bearer\n|`/meetups`|POST|:x:|Body with meetup's banner_id `date`, `description`, `localization` and `title`.|Create a new meetup.|Bearer\n|`/meetups`|PUT|:x:|Body with meetup's banner_id `date`, `description`, `localization` and `title`.|Update a meetup.|Bearer\n|`/meetups/:id`|DELETE|:x:|`id` of the meetup.|Delete a meetup.|Bearer\n|`/scheduled`|GET|:x:| - |Lists logged in user's meetups.|Bearer\n|`/scheduled/:id`|GET|:x:|`id` of the meetup.|Show one logged in user's meetup.|Bearer\n|`/subscriptions`|GET|:heavy_check_mark:| - |Lists logged in user's subscriptions.|Bearer\n|`/subscriptions`|POST|:x:|Body with subscription's `meetup_id`.|Subscribe yourself to a meetup.|Bearer\n|`/subscriptions`|DELETE|:x:|Body with subscription's `meetup_id`.|Unsubscribe yourself from a meetup.|Bearer\n\n\u003e Routes with `Bearer` as auth method expect an `Authorization` header. See [Bearer Token](#bearer-token) section for more information.\n\n### Requests\n* `POST /session`\n\nRequest body:\n```json\n{\n  \"email\": \"johndoe@example.com\",\n  \"password\": \"123456\"\n}\n```\n\n* `POST /users`\n\nRequest body:\n```json\n{\n  \"email\": \"johndoe@example.com\",\n  \"name\": \"John Doe\",\n  \"password\": \"123456\"\n}\n```\n\n* `PUT /users`\n\nRequest body:\n```json\n{\n  \"name\": \"John Doe\",\n  \"email\": \"johndoe@example.com\",\n  \"old_password\": \"123456\",\n  \"password\": \"123456789\",\n  \"confirm_password\": \"123456789\"\n}\n```\n\n* `POST /files`\n\nImage file\n\n\n* `POST /meetups`\n\nRequest body:\n```json\n{\n  \"banner_id\": 1,\n  \"date\": \"2020-12-30\",\n  \"description\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\",\n  \"localization\": \"4795 Denesik Throughway Kaileefurt, NC 07927-4723\",\n  \"title\": \"Creative Planner\"\n}\n```\n\n* `PUT /meetups`\n\nRequest body:\n```json\n{\n  \"banner_id\": 1,\n  \"date\": \"2020-12-31\",\n  \"description\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\",\n  \"localization\": \"64504 Stehr Motorway Tellyfort, IL 33915-6894\",\n  \"title\": \"Lead Quality Director\"\n}\n```\n\n* `PUT /subscriptions`\n\nRequest body:\n```json\n{\n  \"meetup_id\": 1,\n}\n```\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%2Fmeetapp-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiegovictor%2Fmeetapp-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegovictor%2Fmeetapp-api/lists"}