{"id":18715331,"url":"https://github.com/mohamedaemara/fastify-socket-server","last_synced_at":"2026-05-05T23:31:33.141Z","repository":{"id":239750735,"uuid":"800361810","full_name":"MohamedAEmara/Fastify-Socket-Server","owner":"MohamedAEmara","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-16T19:35:13.000Z","size":115,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-19T11:45:56.387Z","etag":null,"topics":["fastify","nodejs","swagger"],"latest_commit_sha":null,"homepage":"https://fastify-socket-server.onrender.com/documentation/","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/MohamedAEmara.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":"2024-05-14T07:29:24.000Z","updated_at":"2024-05-16T19:35:17.000Z","dependencies_parsed_at":"2024-05-15T12:41:35.832Z","dependency_job_id":"d0023aef-f156-4c36-ac58-70871611c8f2","html_url":"https://github.com/MohamedAEmara/Fastify-Socket-Server","commit_stats":null,"previous_names":["mohamedaemara/fastify-socket-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MohamedAEmara/Fastify-Socket-Server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedAEmara%2FFastify-Socket-Server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedAEmara%2FFastify-Socket-Server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedAEmara%2FFastify-Socket-Server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedAEmara%2FFastify-Socket-Server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MohamedAEmara","download_url":"https://codeload.github.com/MohamedAEmara/Fastify-Socket-Server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohamedAEmara%2FFastify-Socket-Server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32672527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["fastify","nodejs","swagger"],"created_at":"2024-11-07T13:08:23.391Z","updated_at":"2026-05-05T23:31:33.125Z","avatar_url":"https://github.com/MohamedAEmara.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastify Socket Server\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Project Structure](#project-structure)\n- [Installation](#installation)\n- [Running the Application](#running-the-application)\n- [API Documentation](#api-documentation)\n- [WebSocket Communication](#websocket-communication)\n- [Testing](#testing)\n- [Dependencies](#dependencies)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Overview\n\nThis project is a Fastify application that implements CRUD operations for a User entity and integrates a WebSocket server to enable bidirectional communication between the client and server. The application includes Swagger documentation for the Fastify endpoints and a Postman collection for testing the WebSocket server.\n\n## Project Structure\n\n- ├── src           \n- │ ├── controllers\n- │ │ └── userController.js\n- │ ├── db\n- │ │ └── db.js\n- │ ├── routes\n- │ │ └── user.route.js\n- │ ├── controllers\n- │ │ └── user.controller.js\n- │ ├── services\n- │ │ └── user.service.js\n- │ └── app.js\n- │── socket-server\n- │ └─── socketServer.js\n- │── prisma\n- │ ├── migrations\n- │ └─── schema.prisma\n- ├── .gitignore\n- ├── package.json\n- ├── package-lock.json\n- ├── docker-compose.yml\n- └── README.md\n`\n\n\n## Installation\n\n1. Clone the repository:\n    \n\n\n    $  git clone https://github.com/MohamedAEmara/fastify-socket-server.git\n   \n\n\n    $  cd fastify-socket-server\n\n\n\n\n2. Install the dependencies:\n\n\n    npm install\n\n\n3. Add .env file and add your enviroment variables\n\n```\n    HOST=localhost\n    PORT=3000\n    PASSWORD_SALT=\"$fdb$10$wH8qdfswE5R3C.6v5fdsZ/ZmM\"\n    JWT_SECRET=\"secretvalue123\"\n    DATABASE_URL=\"postgresql://postgres:1234@localhost:5432/fastifysocket\"\n    \n    ## NOTE: this data base will connect to DB docker container defined in docker-compse.\n```\n\n\n#### Make sure you installed Postgres on your machine\n\n### OR\n\n####  Use the DB configurations in docker-compose.yml file (Make sure you installed Docker)\n  \n\n## Running the Application\n\n1. Start the Fastify server: **this will run DB container and connect fastify server to it. Also will run the socker server**  \n\n\n    ``\n    npm run start:dev \n    ``\n\n\n    In case you don't want to use Docker and have Postgres installed on your machine RUN\n\n\n\n    ``\n    npm run start \n    ``\n\n\n2. The server will be running at http://localhost:3000.\n\n## API Documentation\n\nYou can see Swagger documentation and try it out through the ``deployed server``\n\n- https://fastify-socket-server.onrender.com/documentation/\n\nOR \n\n\nYou can run the server locally and see Swagger documentation at ``/documentaion`` endpoint\n\n- http://localhost:3000/documentation\n\n\n### User Endpoints\n\n- **GET /users:** Retrieve all users\n- **GET /users/:id:** Retrieve a user by ID\n- **POST /users:** Create a new user\n- **PUT /users/:id:** Update a user by ID\n- **DELETE /users/:id:** Delete a user by ID\n\n## WebSocket Communication\n\nThe WebSocket server is implemented using the ws library. It enables bidirectional communication between the client and server.\n\n### How to Test WebSocket\n\n1. Open Postman.\n2. Create a new WebSocket request to ws://localhost:3000.\n3. Send a message to the server.\n4. The server will log the received message and send a response back to the client.\n\nFor more detailed testing, you can use the provided Postman collection.\n\n\n## Testing\n\nTo test the WebSocket server using Postman:\n\n1. Import the Postman collection from test/socketTest.json.\n2. Establish a WebSocket connection to ws://localhost:3000.\n3. Send test messages and verify the responses.\n\n## Postman Testing\n\n\nhttps://github.com/MohamedAEmara/Fastify-Socket-Server/assets/62681515/7d78ccf9-39d9-4cb5-a23e-b2c8d611f923\n\n\n\n## Dependencies\n\n- [Fastify](https://www.npmjs.com/package/fastify) - Fast and low overhead web framework for Node.js\n- [ws](https://www.npmjs.com/package/ws) - Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js\n- [fastify-swagger](https://www.npmjs.com/package/fastify-swagger) - Fastify plugin to serve Swagger UI and JSON\n- [bcrypt](https://www.npmjs.com/package/bcrypt) - For hashing user passwords\n- [@prisma/client](https://www.npmjs.com/package/@prisma/client) - ORM For easier dealing with postgres\n\n## Contributing\n\nContributions are welcome! Please submit a pull request or open an issue to discuss your ideas.\n\n\n## Contact\n\nFor any inquiries or support, please contact [Mohamed Emara](mailto:mohamedemara.dev@gmail.com).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamedaemara%2Ffastify-socket-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohamedaemara%2Ffastify-socket-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamedaemara%2Ffastify-socket-server/lists"}