I created a new Provider in AdonisJS and I want to connect to a websocket server which is running on the same Adonis instance as well.
Following the documentation I see I have to do the steps below:
npm i @adonisjs/websocket-client
Then Import the WebSocket client like so:
import Ws from '@adonisjs/websocket-client' const ws = Ws('ws://localhost:3333')
The thing is that if I do this, I get an error:
SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' import Ws from '@adonisjs/websocket-client'
OK, I understand this is not a
.ts file so I switch to the
const Ws = use('@adonisjs/websocket-client') const ws = Ws('ws://localhost:3333')
SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' export default index;
What can I do?
I would like to push some message when an event occurs on the server and broadcast the information to all connected clients.