
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
ephemeral-socket-service
Advanced tools
This express middleware allows you to accept incoming HTTP POST requests that will be piped through to later HTTP GET requests.
The server acts as a file sharing service but the data is never stored on the server. Instead, the incoming HTTP POST is accepted and then stalled until the HTTP GET request is made. In order to know what URL to use for the HTTP GET request, we write a partial response to the HTTP POST but do not close the stream.
Here is how it might look:
# Create express server
express = require 'express'
app = express()
# Initialize middleware
service = require('ephemeral-socket-service').attach(app)
# Respond to events
service.on 'socket:opened', (socket, socketId, query) ->
socket.res.writeHead(200)
socket.res.write("Ephemeral socket open with ID #{socketId}")
service.on 'socket:end', (socket, stats) ->
socket.res?.write('\n\nUpload complete. Socket deleted.\n')
socket.res?.end()
service.on 'socket:timeout', (socket) ->
socket.res?.write('\n\nTimed out. No one requested your socket.\n')
socket.res?.end()
service.on 'error:not-found', (req, res) ->
res.status(404).send('Not found')
# Serve
app.set('port', 9000)
server = app.listen(app.get('port'), ->
console.log('Listening on %s', server.address().port)
)
EphemeralSocketService.attach()
takes an option hash as its second argument. The available options are:
key | default | description |
---|---|---|
ttl | 600 | Time (in seconds) that a socket may stay open before it times out |
maxUploadBytes | 2^30 (1 GB) | Set the max number of bytes allowed to be piped through a socket. HTTP POSTs will be rejected with a 413 status code if they exceed this limit |
reservations | false | Adds /reserve middleware to allow users to create an ephemeral socket before creating an HTTP POST. This is useful when scripting this service within a web browser as most don't support streaming HTTP POST responses. |
requiredReferer | null | RECOMMENDED if you are using reservations. If defined with a string like "http://localhost:9000", this will restrict reservations to that specific referer. |
ids | {...} | An object for creating the socket IDs. See ids.coffee |
FAQs
Express middleware for an ephemeral socket service
The npm package ephemeral-socket-service receives a total of 2 weekly downloads. As such, ephemeral-socket-service popularity was classified as not popular.
We found that ephemeral-socket-service 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.