{"_id":"collab.js","name":"collab.js","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"collab.js","version":"1.0.0","description":"Real-time collaboration tools for applications with WebSocket communication, version control, user roles, and notifications.","main":"src/index.js","scripts":{"start":"node src/index.js","test":"echo \"No tests specified\" && exit 0"},"dependencies":{"bcrypt":"^5.1.1","dotenv":"^16.2.0","express":"^4.18.2","jsonwebtoken":"^9.0.1","mongoose":"^7.4.1","ws":"^8.7.0"},"keywords":["collaboration","websocket","real-time","version-control","notifications"],"author":{"name":"Melih Deniz Kayalar"},"license":"MIT","_id":"collab.js@1.0.0","_nodeVersion":"20.16.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-fx+c8eANrweRnafurw4r0KxDPkuJW3HDaGfW1d9DtPDBuI5EL4okpMev2aROoXa+CPkdBMVCfczTysFiLvgU/A==","shasum":"5495968bcf6e1e2d3df74c850ef2a3b0fd0d7f8d","tarball":"https://registry.npmjs.org/collab.js/-/collab.js-1.0.0.tgz","fileCount":15,"unpackedSize":10425,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDPWOxjfItsqfk1XGWE8O//6Nnen5T3LjaIIWPXmRjudwIgWSCup9iFSUa8/GSjZEww1dkL7XjmMjntNpWvALU2sOM="}]},"_npmUser":{"name":"lillayly","email":"exalyrua@gmail.com"},"directories":{},"maintainers":[{"name":"lillayly","email":"exalyrua@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/collab.js_1.0.0_1722261549418_0.7195057847020876"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-29T13:59:09.417Z","1.0.0":"2024-07-29T13:59:09.610Z","modified":"2024-07-29T13:59:09.845Z"},"maintainers":[{"name":"lillayly","email":"exalyrua@gmail.com"}],"description":"Real-time collaboration tools for applications with WebSocket communication, version control, user roles, and notifications.","keywords":["collaboration","websocket","real-time","version-control","notifications"],"author":{"name":"Melih Deniz Kayalar"},"license":"MIT","readme":"# collab.js\r\n\r\n`collab.js` is a comprehensive real-time collaboration tool designed for modern applications. It provides essential features for real-time communication, version control, user role management, and notifications, allowing multiple users to collaborate on documents simultaneously.\r\n\r\n## Features\r\n\r\n- **WebSocket Communication**: Enables real-time updates and interaction between users.\r\n- **Version Control**: Track and manage changes made to documents.\r\n- **User Role Management**: Define and control user roles and permissions.\r\n- **Notifications**: Receive real-time alerts about document changes.\r\n\r\n## Installation\r\n\r\nTo get started with `collab.js`, you need to install it via npm:\r\n\r\n```bash\r\nnpm install collab.js\r\n```\r\n\r\n## Usage\r\n\r\n### Initialize Server\r\n\r\nYou can use `collab.js` by importing it into your Node.js application and setting up the server:\r\n\r\n```javascript\r\nconst { app, server, websocketService } = require('collab.js');\r\n\r\n// Configure your server and WebSocket\r\nconst PORT = process.env.PORT || 3000;\r\nserver.listen(PORT, () => {\r\n    console.log(`Server is running on port ${PORT}`);\r\n});\r\n```\r\n\r\n### API Endpoints\r\n\r\n#### Authentication\r\n\r\n- **Register**: `POST /api/auth/register`\r\n  - Registers a new user.\r\n  \r\n- **Login**: `POST /api/auth/login`\r\n  - Logs in a user and returns a JWT token.\r\n\r\n#### Collaboration\r\n\r\n- **Save Change**: `POST /api/collaboration/changes`\r\n  - Saves a change to a document. Requires a valid JWT token.\r\n\r\n- **Get Document**: `GET /api/collaboration/documents/:id`\r\n  - Retrieves a document by its ID. Requires a valid JWT token.\r\n\r\n### WebSocket\r\n\r\nTo enable real-time updates, establish a WebSocket connection:\r\n\r\n```javascript\r\nconst WebSocket = require('ws');\r\nconst ws = new WebSocket('ws://localhost:3000');\r\n\r\n// Handle incoming messages\r\nws.onmessage = (event) => {\r\n    const data = JSON.parse(event.data);\r\n    console.log('Received:', data);\r\n};\r\n\r\n// Send a change message\r\nws.send(JSON.stringify({\r\n    type: 'change',\r\n    data: { documentId: 'doc123', change: 'Updated content' }\r\n}));\r\n```\r\n\r\n## Environment Configuration\r\n\r\nYou can customize the following environment variables by creating a `.env` file in the root of your project:\r\n\r\n```dotenv\r\nPORT=3000\r\nMONGODB_URI=mongodb://localhost/collabjs\r\nACCESS_TOKEN_SECRET=your_jwt_secret\r\n```\r\n\r\n- **PORT**: The port on which the server will run (default: 3000).\r\n- **MONGODB_URI**: MongoDB connection URI (default: `mongodb://localhost/collabjs`).\r\n- **ACCESS_TOKEN_SECRET**: JWT secret for authentication (default: `your_jwt_secret`).\r\n\r\nModify these values according to your needs.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License.","readmeFilename":"README.md"}