Gathering detailed insights and metrics for adonis-vue-websocket
Gathering detailed insights and metrics for adonis-vue-websocket
npm install adonis-vue-websocket
Typescript
Module System
Node Version
NPM Version
JavaScript (87.94%)
Vue (7.53%)
CSS (2.9%)
HTML (1.63%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
15,989
Last Day
1
Last Week
27
Last Month
89
Last Year
2,147
2 Stars
13 Commits
4 Forks
1 Watchers
26 Branches
2 Contributors
Updated on Feb 19, 2022
Minified
Minified + Gzipped
Latest Version
2.0.2
Package Id
adonis-vue-websocket@2.0.2
Unpacked Size
894.05 kB
Size
359.93 kB
File Count
53
NPM Version
6.10.2
Node Version
11.15.0
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
80%
27
Compared to previous week
Last Month
25.4%
89
Compared to previous month
Last Year
-17.8%
2,147
Compared to previous year
1
This package add new layer for use original AdonisWSClient in your vue.js project:
1//For global acceess 2Vue.ws 3 4//In vue component 5this.$ws
For example you can handle adonisWS events in your vue components:
1this.$ws.$on(`${topicName}|ABOUT_MESSAGE`, d => console.log(d))
Emit events from Vue components you can:
1//if this topic does not exist, $emitToServer automatic trying to create it 2this.$ws.$emitToServer(topicName, 'hello', {message: 'message})
npm
1npm install adonis-vue-websocket
yarn
1yarn add adonis-vue-websocket
You can to plug original AdonisWSClient and connect with library:
1import Ws from '@adonisjs/websocket-client' 2import WsPlugin from 'adonis-vue-websocket' 3Vue.use(WsPlugin, { adonisWS: Ws })
Or
I recommend this way: add AdonisWS in index.html (for disable native AdonisJS logs):
1<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.4.3/polyfill.min.js"></script> 2<script src="https://unpkg.com/@adonisjs/websocket-client@1.0.9/dist/Ws.browser.min.js"></script>
and connect with library in main.js:
1import WsPlugin from 'adonis-vue-websocket' 2Vue.use(WsPlugin, { adonisWS: window.adonis.Ws })
Create file src/WsSubscriptions.js with content:
1import Vue from "vue"; 2 3const userTopicSubscriptions = id => { 4 if (id) { 5 let subscription = Vue.ws.socket.getSubscription(`user:${id}`); 6 if (!subscription) { 7 subscription = Vue.ws.subscribe(`user:${id}`); 8 } 9 subscription.on("HELLO_EVENT", data => { 10 console.log('Hello (event handled in src/WsSubscriptions.js)', data) 11 }); 12 } 13}; 14 15export default async () => { 16 return new Promise((resolve, reject) => { 17 Vue.ws.disconnect() 18 Vue.ws.connect( 19 { 20 wsDomain: "ws://localhost:3333", 21 jwtToken: null 22 }, 23 { 24 path: 'adonis-ws', 25 reconnectionAttempts: 300, 26 reconnectionDelay: 5000 27 } 28 ); 29 Vue.ws.socket.on("open", () => { 30 userTopicSubscriptions(1); 31 resolve() 32 }); 33 34 // FOR EXAMPLE you can observe for userId or another variable from Vuex 35 // store.watch( 36 // () => store.getters.vgUserUid, 37 // async id => { 38 // if (id) { 39 // userTopicSubscriptions(uid); 40 // } 41 // } 42 // ); 43 }) 44};
In app.vue:
1<template> 2 <div id="app"> 3 <div id="nav"> 4 <router-link to="/">Home</router-link> | 5 <router-link to="/about">About</router-link> 6 </div> 7 <router-view v-if="!loading"/> 8 </div> 9</template> 10 11<script> 12import WsSubscriptions from './WsSubscriptions' 13export default { 14 data () { 15 return { 16 loading: true 17 } 18 }, 19 async created() { 20 await WsSubscriptions() 21 this.loading = false 22 } 23} 24</script>
You can handle events in any .js and .vue files and components, for example in vue component:
1<template> 2 <div class="about"> 3 <h1>This is an about page</h1> 4 <el-input v-model="message"/> 5 <el-button @click="sendHello">Send!</el-button> 6 </div> 7</template> 8<script> 9const topicName = 'user:1' 10export default { 11 data() { 12 return { 13 message: 'Hello from about page!' 14 } 15 }, 16 mounted() { 17 this.$ws.$on(`${topicName}|ABOUT_MESSAGE`, this.handleAboutMessageEvent) 18 this.$ws.$on('ABOUT_MESSAGE', this.handleAboutMessageEvent) 19 }, 20 beforeDestroy(){ 21 //Remove listeners when component destroy 22 this.$ws.$off(`${topicName}|ABOUT_MESSAGE`, this.handleAboutMessageEvent); 23 this.$ws.$off('ABOUT_MESSAGE', this.handleAboutMessageEvent); 24 }, 25 methods: { 26 handleAboutMessageEvent(data){ 27 console.log("handled in src/views/About.vue", data) 28 }, 29 sendHello(){ 30 this.$ws.$emitToServer(topicName, 'hello', {message: this.message}) 31 } 32 } 33} 34</script>
1git clone https://github.com/reg2005/adonis-vue-websocket.git 2cd adonis-vue-websocket
1cd example/back 2cp .env.example .env 3npm install 4adonis serve --dev
1cd example/front 2npm install 3yarn serve
And open front in your browser
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/12 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
108 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-03-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More