{"id":14957628,"url":"https://github.com/aaron5670/expressjs-socketio-boilerplate","last_synced_at":"2025-05-02T07:32:29.993Z","repository":{"id":40719586,"uuid":"257680632","full_name":"aaron5670/ExpressJS-SocketIO-Boilerplate","owner":"aaron5670","description":"📦 Simple Express.js \u0026 Socket.io Boilerplate","archived":false,"fork":false,"pushed_at":"2023-02-01T19:47:24.000Z","size":138,"stargazers_count":47,"open_issues_count":6,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-12T16:02:46.188Z","etag":null,"topics":["api","auth","authentication","boilerplate","boilerplate-node","boilerplate-template","documentation","documentation-generator","express","express-js","io-boilerplate","node-js","nodejs","nodejs-server","passport","passportjs","socket","socket-io","socket-server","socketio-server"],"latest_commit_sha":null,"homepage":"","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/aaron5670.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}},"created_at":"2020-04-21T18:24:51.000Z","updated_at":"2024-08-29T18:59:57.000Z","dependencies_parsed_at":"2023-02-17T10:16:03.014Z","dependency_job_id":null,"html_url":"https://github.com/aaron5670/ExpressJS-SocketIO-Boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaron5670%2FExpressJS-SocketIO-Boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaron5670%2FExpressJS-SocketIO-Boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaron5670%2FExpressJS-SocketIO-Boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaron5670%2FExpressJS-SocketIO-Boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aaron5670","download_url":"https://codeload.github.com/aaron5670/ExpressJS-SocketIO-Boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224305847,"owners_count":17289446,"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","auth","authentication","boilerplate","boilerplate-node","boilerplate-template","documentation","documentation-generator","express","express-js","io-boilerplate","node-js","nodejs","nodejs-server","passport","passportjs","socket","socket-io","socket-server","socketio-server"],"created_at":"2024-09-24T13:15:15.760Z","updated_at":"2024-11-12T16:04:33.282Z","avatar_url":"https://github.com/aaron5670.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📦 Express.js \u0026 Socket.io Boilerplate\nSimple Express.js \u0026 Socket.io Boilerplate.\n\n\n## ✨ Features\n\n- [x] Express 4.16\n- [x] Mongoose 5.7\n- [x] Passport.js with Bcrypt.js\n  - Login endpoint\n  - Register endpoint\n  - Username availability check endpoint\n  - Authenticated endpoint\n  - Logout endpoint\n- [x] Socket.io integration for real-time, bidirectional and event-based communication.\n- [x] Generates automatically API docs based on Express existing routes with Swagger UI.\n- [ ] Social login / register integration.\n\n\n## 📝 Getting Started\n\n```\ngit clone https://github.com/aaron5670/ExpressJS-SocketIO-Boilerplate.git\n\ncd expressjs-socketio-boilerplate\n\nnpm install\n\n// Optional: if you want dummy data, then run this seed file\nnode seed.js\n\nnode server.js\n```\n\n## ⚡ Create Socket.io connection\nInstall on your client-side (web) application the module [socket.io-client](https://www.npmjs.com/package/socket.io-client).\n```\nnpm install socket.io-client\n```\n\nThen create a connection with the following code:\n```javascript\n// with ES6 import\nimport io from 'socket.io-client';\n \nconst socket = io('http://localhost:3005');\n```\n\nFor more info you can read the official Socket.io documentation:\n- [Official docs](https://socket.io/docs/)\n- [Server API](https://socket.io/docs/server-api/)\n- [Client API](https://socket.io/docs/client-api/)\n\n## 📓 How to document the Swagger UI endpoint API\n```javascript\n/**\n * @typedef ResponseJSON\n * @property {string} username - user's username - eg: janet\n * @property {string} message - message - eg: This is a authenticated route!\n */\n/**\n * Dashboard endpoint only allowed for authenticated users\n * @route GET /api/v1/auth/dashboard\n * @group Auth\n * @returns {ResponseJSON.model} 200\n * @produces application/json\n */\nrouter.get('/dashboard', authenticationMiddleware(), (req, res) =\u003e {\n    return res.json({\n        username: req.session.passport.user.username,\n        message: 'This is a authenticated route!'\n    });\n});\n```\nIf you are running this boilerplate on you localhost you can see the Swagger UI documentation on: http://localhost:3005/api-docs/.\n\n**Note:** *Check if your port number is the same as your [configuration](https://github.com/aaron5670/ExpressJS-SocketIO-Boilerplate/blob/master/config.js)*.\n\n### 📌 Swagger UI example\n\u003cimg src=\"https://github.com/aaron5670/ExpressJS-SocketIO-Boilerplate/blob/master/swaggerExample.jpg?raw=true\" alt=\"Swagger UI Docs\" width=\"500\"/\u003e\n\n## 🚀 Endpoints\nThe following endpoints are available\n\n#### Login\n\n```\nurl:    /api/v1/auth/login\nmethod: POST\n```\n\nThis request expects the following body:\n\n```json\n{\n  \"username\": \"jane\", \n  \"password\": \"securepassword1\"\n}\n```\n\nIt will response the client the following object after a successful login:\n\n```json\n{\n  \"success\": true,\n  \"username\": \"jane\",\n  \"message\": \"Successful login, welcome!\"\n}\n```\n\n#### Register\n\n```\nurl:    /api/v1/auth/register\nmethod: POST\n```\n\nThis request expects the following body:\n\n```json\n{\n  \"name\": \"John Doe\",\n  \"username\": \"john\",\n  \"password\": \"password123\"\n}\n```\n\nIt will response the client the following object after a successful register:\n\n```json\n{\n  \"success\": true,\n  \"message\": \"User is successfully registered!\"\n}\n```\n\n#### Username availability check\n\n```\nurl:             /api/v1/auth/username-availability\nmethod:          GET\nquery parameter: username\n```\n\nThis request expects a request like:\n\n```\nhttps://localhost:3005/api/v1/auth/username-availability?username=john\n```\n\nIt will response the client the following object after a successful request:\n\n```json\n{\n  \"usernameAlreadyInUsage\": true\n}\n```\n\n#### Logout\n\n```\nurl:    /api/v1/auth/logout\nmethod: GET\n```\n\nIt will response the client the following object after a successful request:\n\n```json\n{\n  \"success\": true\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaron5670%2Fexpressjs-socketio-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faaron5670%2Fexpressjs-socketio-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaron5670%2Fexpressjs-socketio-boilerplate/lists"}