-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider using a stream-based server such as filed
#80
Comments
Yup 👍 this is a bit of re-shuffling code but I think it will come out cleaner in the end. |
Starting to look into this which will hopefully fix #124, #119 and some other irks. Lots of options.. might use a few of these: Or maybe just use Ideally it can be refactored so the core of budo can be split out (see #122) and easily used in somebody's custom server/express app. I haven't done a lot of server/backend stuff so any suggestions are welcome. /cc @yoshuawuyts |
I wouldn't use Only Here's a lil example of a what a server with these packages would look like: const boleStream = require('bole-stream')
const httpNdjson = require('http-ndjson')
const sizeStream = require('size-stream')
const summary = require('server-summary')
const stdout = require('stdout-stream')
const pumpify = require('pumpify')
const bole = require('bole')
const http = require('http')
module.exports = createServer
function createServer (argv) {
bole.output({ level: argv.logLevel, stream: stdout })
const logStream = boleStream({ level: argv.logLevel })
const port = argv.port
// create server
const server = http.createServer(function (req, res) {
const httpLogger = httpNdjson(req, res)
httpLogger.pipe(logStream, { end: false })
const size = sizeStream()
size.once('size', function (size) {
httpLogger.setContentLength(size)
})
const sink = pumpify(size, res)
api(req, res).pipe(sink)
})
// start the server on port
server.listen(port, summary(server))
} Here |
Refactored the server handling in I ended up using Still some more work to do: modularization, HTTPS support, etc. But hopefully this fixes the major pain points with the previous server code. |
Per #73 (comment)
The text was updated successfully, but these errors were encountered: