Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
sails-socket
Advanced tools
A Promise-based implementation of Sails Socket library inspired by axios.
simply install it with node or yarn:
npm install sails-socket
You have to provide socket url
to the connect
method and you're off to go.
import SailsSocket from 'sails-socket'
...
SailsSocket.connect('http://your-socket-server/');
SailsSocket.get('/hello').then(function(jwr) {
console.log(jwr.body);
}).catch(function(jwr) {
console.log(jwr.error);
})
The implemented methods are: connect, disconnect, get, post, put, delete, request, on, off, setHeader
It has to be called before using any other functions, it would throw an error if there was already another socket connection.
const initializeParams = {url: 'http://sails-server.com/'}
socket = SailsSocket.connect(initializeParams)
initializeParams
can be any sails
configuration option as an objec like url, transports, headers and etc. see sails documentations for more details.
it returns the created socket. although it can be accessible later via static SailsSocket.activeSocket
property.
it disconnects current active socket.
SailsSocket.disconnect()
it sends a get request corresponding to io.socket.get()
and returns a promise.
SailsSocket.get(url, data)
it sends a post request corresponding to io.socket.post()
and returns a promise.
SailsSocket.post(url, data)
it sends a put request corresponding to io.socket.put()
and returns a promise.
SailsSocket.put(url, data)
it sends a delete request corresponding to io.socket.delete()
and returns a promise.
SailsSocket.delete(url, data)
it sends a customizable request corresponding to io.socket.request()
and returns a promise.
SailsSocket.request(options)
it starts listening for server-sent events from Sails with specified eventIdentity
corresponding to io.socket.on()
.
SailsSocket.on(url, callback)
unbind the specified event handler corresponding to io.socket.off()
.
SailsSocket.off(url, callback)
sets header to the active socket
SailsSocket.setHeader(headers)
headers object
please check for closed issues before opening new issues.
FAQs
simple promise base socket for sails js
The npm package sails-socket receives a total of 0 weekly downloads. As such, sails-socket popularity was classified as not popular.
We found that sails-socket demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.