{"id":17651742,"url":"https://github.com/diegovictor/chatter","last_synced_at":"2025-08-04T01:33:56.603Z","repository":{"id":98963876,"uuid":"359953099","full_name":"DiegoVictor/chatter","owner":"DiegoVictor","description":"Project built during Rocketseat's Next Level Week #5","archived":false,"fork":false,"pushed_at":"2025-06-19T13:09:28.000Z","size":1690,"stargazers_count":16,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-13T17:43:34.846Z","etag":null,"topics":["api","chatter","editorconfig","eslint","nextlevelweek","nlw","node","nodejs","prettier","rocketseat","sqlite","ts","typeorm","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,"zenodo":null}},"created_at":"2021-04-20T21:16:24.000Z","updated_at":"2025-06-19T13:09:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"2ab38017-9712-4b2f-bc52-b708d53a650d","html_url":"https://github.com/DiegoVictor/chatter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DiegoVictor/chatter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fchatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fchatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fchatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fchatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DiegoVictor","download_url":"https://codeload.github.com/DiegoVictor/chatter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiegoVictor%2Fchatter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268636273,"owners_count":24282071,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["api","chatter","editorconfig","eslint","nextlevelweek","nlw","node","nodejs","prettier","rocketseat","sqlite","ts","typeorm","typescript"],"created_at":"2024-10-23T11:43:28.086Z","updated_at":"2025-08-04T01:33:56.518Z","avatar_url":"https://github.com/DiegoVictor.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chatter\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/DiegoVictor/chatter/config.yml?logo=github\u0026style=flat-square)](https://github.com/DiegoVictor/chatter/actions)\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/chatter?logo=codecov\u0026style=flat-square)](https://codecov.io/gh/DiegoVictor/chatter)\n[![MIT License](https://img.shields.io/badge/license-MIT-green?style=flat-square)](https://raw.githubusercontent.com/DiegoVictor/chatter/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=Chatter\u0026uri=https%3A%2F%2Fraw.githubusercontent.com%2FDiegoVictor%2Fchatter%2Fmaster%2FInsomnia_2024-08-12.json)\n\nPermit to register users and its settings, also manage websocket connections and messages. The app has friendly errors, validation, also a simple versioning was made.\n\n## Table of Contents\n* [Installing](#installing)\n  * [Configuring](#configuring)\n    * [.env](#env)\n    * [SQLite](#sqlite)\n      * [Migrations](#migrations)\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 database: [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### .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|PORT|Port number where the app will run.|`3333`\n|DOCS_URL|An url to docs where users can find more information about the app's internal code errors.|`https://github.com/DiegoVictor/chatter#errors-reference`\n\n### SQLite\nStore the users, settings, messages and connections. For more information to how to setup your database see:\n* [typeorm](https://typeorm.io/#/using-ormconfig)\n\u003e You can find the application's `ormconfig.js` file in the root folder.\n\n#### Migrations\nRemember to run the database migrations:\n```\n$ yarn ts-node-dev ./node_modules/typeorm/cli.js migration:run -- -d ./src/database/datasource.ts\n```\nOr:\n```\n$ yarn typeorm migration:run -- -d ./src/database/datasource.ts\n```\n\u003e See more information on [TypeORM Migrations](https://typeorm.io/#/migrations).\n\n# Usage\nTo start up the app run:\n```\n$ yarn dev:server\n```\nOr:\n```\nnpm 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\": 400,\n  \"error\": \"BadRequest\",\n  \"message\": \"Setting already exists\",\n  \"code\": 140,\n  \"docs\": \"https://github.com/DiegoVictor/chatter#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|Setting already exists|Already exists a settings to provided `id`.\n|144|Setting not found|The provided `id` not references an existing setting in the database.\n|244|User not found|The user `id` sent does not references an existing user in the database.\n|245|User not found|Is not possible to retrieve messages from a user not found 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```\nPOST http://localhost:3333/v1/settings\n```\n\n## Routes\n|route|HTTP Method|params|description\n|:---|:---:|:---:|:---:\n|`/settings/:id`|GET|`id` of the setting.|Return the user's setting.\n|`/settings`|POST|Body with settings `user_id` and `chat` property.|Create new setting.\n|`/settings/:id`|PUT|`id` of the setting and body with `chat` new value.|Update an user's setting.\n|`/users`|POST|Body with user's `email`.|Create a new user.\n|`/users/:id/messages`|GET|`id` of the user.|Return user's messages.\n|`/messages`|POST|Body with message data.|Save user new message.\n\n### Requests\n* `POST /settings`\n\nRequest body:\n```json\n{\n  \"user_id\": \"17c6f66d-a24b-45e0-8c3f-2b3411e51fe8\",\n  \"chat\": true\n}\n```\n\n* `PUT /settings/:id`\n\nRequest body:\n```json\n{\n  \"chat\": true\n}\n```\n\n* `POST /users`\n\nRequest body:\n```json\n{\n  \"email\": \"johndoe@example.com\"\n}\n```\n\n* `POST /messages`\n\nRequest body:\n```json\n{\n  \"user_id\": \"d01bc88b-15cb-4478-830f-edc44577d707\",\n  \"admin_id\": null,\n  \"text\": \"Lorem ipsum doolor sit amet\"\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%2Fchatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiegovictor%2Fchatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegovictor%2Fchatter/lists"}