{"id":16184376,"url":"https://github.com/mattmezza/phava-chat-backend","last_synced_at":"2025-06-25T01:13:14.127Z","repository":{"id":79954406,"uuid":"125290605","full_name":"mattmezza/phava-chat-backend","owner":"mattmezza","description":"A simple chat backend written in phava","archived":false,"fork":false,"pushed_at":"2018-03-19T12:38:38.000Z","size":25,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-25T01:12:59.263Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/mattmezza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","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":"2018-03-15T00:25:24.000Z","updated_at":"2018-05-31T21:50:06.000Z","dependencies_parsed_at":"2023-06-25T22:59:53.361Z","dependency_job_id":null,"html_url":"https://github.com/mattmezza/phava-chat-backend","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mattmezza/phava-chat-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattmezza%2Fphava-chat-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattmezza%2Fphava-chat-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattmezza%2Fphava-chat-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattmezza%2Fphava-chat-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattmezza","download_url":"https://codeload.github.com/mattmezza/phava-chat-backend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattmezza%2Fphava-chat-backend/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261783442,"owners_count":23208954,"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-10T07:09:59.434Z","updated_at":"2025-06-25T01:13:14.110Z","avatar_url":"https://github.com/mattmezza.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"phava-chat-backend\n=======\n\n# Design rationale\n\nSince OO programming is not that much suitable for relational DBs, I decoupled the model object representation from the relational DB logic using the Data Access Object pattern.\n# Install and usage\n\nDevelopment\n- `export CHAT_DB=\"sqlite:/Users/Matt/Development/phava-chat-backend/tests/data/test.db\"`\n- `composer install`\n- `composer migrate:test`\n- `php -S localhost:8000 -t public`\n\nTesting\n- `export CHAT_DB=\"sqlite:/Users/Matt/Development/phava-chat-backend/tests/data/test.db\"`\n- `PORT=8000 composer test`\n\nProduction\n- `export CHAT_DB=\"sqlite:/Users/Matt/Development/phava-chat-backend/data/chat.db\"`\n- `composer install`\n- `composer migrate`\n- `php -S localhost:8000 -t public`\n\n# REST quick specs\n\nEvery call should have a header `X-USERID` set to an int value representing the user id. This is used for authentication.\n\n## getting messages\n\n`GET /messages?page=0\u0026perpage=20` with `page` and `perpage` being optional (with default vale `0` and `20`) and establishing how many messages will be fetched and which portion of the data will be given.\n### Possible errors\nIt can throw a `403` if no `X-USERID` header is given (or if it is not valid).\n### Example of successful reply\n```json\n[\n  {\n    \"id\": 1,\n    \"sender\": 2,\n    \"body\": \"Ohhh mi rispondi???\",\n    \"sentAt\": {\n      \"date\": \"2018-03-19 04:08:50.000000\",\n      \"timezone_type\": 3,\n      \"timezone\": \"UTC\"\n    }\n  }\n]\n```\n\n## sending messages\n\n`POST /messages/send` with two params specified, `recipient` (that must be set to an int value) and `text` that represents the message to be sent.\n\n### Possible errors\n\nIt can throw two errors: Invalid Recipient (when the recipient is not an integer) and Missing Recipient (when the recipient is not specified).\n\n### Example of successful reply\n\n```json\n{\n  \"status\": 201,\n  \"title\": \"Message sent\",\n  \"detail\": \"Message sent with ID 2 at 19/03/2018 04:37:36\"\n}\n```\n\n## error messages\n\n### Missing or invalid header X-USERID\n\nThrown when the `X-USERID` header is either not set or not valid (it must be an integer). Returns a 403.\n\n```json\n{\n  \"status\": 403,\n  \"type\": \"https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403\",\n  \"title\": \"Forbidden\",\n  \"detail\": \"Each request should come with a header field `X-USERID` set to an integer representing the user id of the client.\",\n  \"instance\": \"http://localhost:8000/messages\",\n  \"error_code\": \"FORBIDDEN\"\n}\n```\n\n### Missing recipient\n\nThrown when during the message send a recipient is not specified. Returns a 400.\n\n```json\n{\n  \"status\": 400,\n  \"type\": \"https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400\",\n  \"title\": \"Bad Request\",\n  \"detail\": \"You didn't specify a `recipient` numeric field.\",\n  \"instance\": \"http://localhost:8000/messages/send\",\n  \"error_code\": \"MISSING_RECIPIENT\"\n}\n```\n\n### Invalid recipient\n\nThrown when during the message send the recipient is not valid (it must be an integer). Returns a 400.\n\n```json\n{\n  \"status\": 400,\n  \"type\": \"https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400\",\n  \"title\": \"Bad Request\",\n  \"detail\": \"The recipient you specified is invalid, pleasespecify a `recipient` integer field.\",\n  \"instance\": \"http://localhost:8000/messages/send\",\n  \"error_code\": \"INVALID_RECIPIENT\"\n}\n```\n\n### Internal error\n\nThrown when some internal components fail or on system error. Returns a 500. The detail property, when available, contains a description of the generated error.\n\n```json\n{\n  \"status\": 500,\n  \"type\": \"https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500\",\n  \"title\": \"Internal Server Error\",\n  \"detail\": \"Description of the error\",\n  \"instance\": \"http://localhost:8000/messages\",\n  \"error_code\": \"INTERNAL_SERVER_ERROR\"\n}\n```\n\n### Method not allowed\n\nThrown when trying to call an endpoint with an unsupported method. It returns a 405. The instance field reports the hit endpoint.\n\n```json\n{\n  \"status\": 405,\n  \"type\": \"https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405\",\n  \"title\": \"Method Not Allowed\",\n  \"detail\": \"The method POST is not allowed methods are GET\",\n  \"instance\": \"http://localhost:8000/messages\",\n  \"error_code\": \"NOT_ALLOWED\"\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattmezza%2Fphava-chat-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattmezza%2Fphava-chat-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattmezza%2Fphava-chat-backend/lists"}